No internet inside the Docker?
I have deployed two services, frontend (NextJS) and backend (NestJS).
From the frontend (backend), I am trying to access the backend (HTTP Request).
But I am getting 404.
I don't want to use the internal URL.
Also, I have just recently connected to sub-domains. Is it possible they haven't been updated yet inside the docker?
Thank you!
75 Replies
Project ID:
4246fe3e-d361-4321-a202-34c1691a3e3c
4246fe3e-d361-4321-a202-34c1691a3e3c
show your errors and the exact urls you are trying to use that return 404
How am I supposed to copy the errors? 🤣
copy paste, screenshots, etc
I doesn't fit the entire screen
and it's not copyable
it absolutely is copy-able, but use this https://bookmarklets.up.railway.app/log-downloader/
This is postman from my computer (works)
okay now please show me he code that makes this same request
This it the instance of axios
This is the code, not sure it will tell you a lot
okay and let's see what you have set for that environment variable in the railway service please
That thing is that I am getting 404
Even if you ping from your computer
https://api.clickvote.dev/users/self
You will not get 404
Yup, one moment
side question, are you building with a dockerfile or nixpacks?
nixpacks
have you done a sanity check console log for that environment variable right before you initialise the axios instance?
You can see inside the 404 error that it write the path
so it works
what version of node are you using locally
in the baseUrl
v18.9.1
what version is Railway using
Would it be possible that the DNS is not yet updated inside the docker files?
One moment
I will check
the containers use Google's public dns resolver, and your domain resolves properly with Google's dns, besides if it was a network or dns issue you would not get a 404
Is there any way to ssh into the containers?
nope
Is there any reason the I won't be able from inside the container to turn into a public URL?
sorry I didn't quite understand that
but I assume the next app works locally?
I am sending a request from the NextJS backend to the NestJS backend
the request goes within the container
and not from the client
I can also use the privateUrl for this, but I am avoiding it.
I don't want to do it at the moment
can I ask why you don't want to use the private domain?
it's an open-source project
https://github.com/clickvote/clickvote
GitHub
GitHub - clickvote/clickvote: Add upvotes, likes, and reviews to an...
Add upvotes, likes, and reviews to any context ⭐️. Contribute to clickvote/clickvote development by creating an account on GitHub.
every person can use their on configuration
So I don't want to force this logic
gotcha
so are you calling a separate railway service from your next backend? or are calling yourself in a hairpin configuration
it might be that your url is appending an extra slash at the end?
i remember that nestjs (or springboot) if i tried this url
https://example.com
but would if i tried this https://example.com/I mean I don't see anything wrong, but there are no issues calling that url from within a railway service as you can see here
https://utilities.up.railway.app/request-test?url=https://api.clickvote.dev/users/self&method=get
this test makes the request inside of the railway service
so same type of thing you get a 404 for
I of course get 401 since I'm unauthorized, but it's not a 404
Yes 401 is perfect
but 404 is weird
so I'm really sorry I can't be of help since I don't actually see anything wrong with your code or setup, but I am very confident in saying this is a code issue
You have probably heard it a million of times, but it works locally 🤣
yep and I've probably said this a million times, that unfortunately doesn't rule out this being a code issue
it is an entirely different environment from your local environment after all, your code has to be flexible (for lack of a better word)
I just interesting because I also don't see any log of errors
or anything in the backend
try to plug a nestjs logger to log every request
I will try to connect morgen
I doubt it will work
but will try it now
yeah, this would be very hard to debug without logging/telemetry
but as I have proved it is totally possible to call that url from within the code in a railway service, so the only problem area left is your code
But it's a different network no?
I wonder if you will get the same from the same network
that doesn't matter, if this was a network issue you would not just be getting a 404
btw, you could probably just log the response you get from the server, nestjs returns the path for you
https://api.clickvote.dev/users/selff
yep thalles couldn't be more right, logging!!! log everything
never underestimate how useful debug logs can be
I added morgan
Will test it now 🙂
might also be worth adding debug logs for the incoming requests on the backend as well
Yup it's what I thought, it's not getting into the server
what are you hitting that is returning the 404 then?
i've thought that you're probably hitting yourself?
as i said, log the response from the server
you'll get your answer
Ah no
here the logger works
it get to the server
Ah not it's just me
haha opening the URL directly
it's not getting
Actually inside the "data"
it show nextjs error
I think it's coming back here:
https://app.clickvote.dev/user/self
Which is the nextjs app
it's probably something that you're doing here, just get the
axiosInstance
and do the request to see if that worksbut it's weird because in the request headers it has
responseUrl: 'https://api.clickvote.dev/users/self';,
that's why i moved away from axios
fetch ftw
and in the response headers it has
NextJs headers
Yup, Axios bug. Sorry for wasting your time 🙏🏻
no worries at all, no time was wasted
Railways rocks!
It was so easy to set the NX monorepo 🚀
well, it was easy because you came to railway with a properly configured nx monorepo
lots of people come with broken nx/turbo monorepos and have a horrible time because nixpacks doesn't know what to do with their repo, it also doesn't help that the user in that case also doesn't know what to do with their repo
I must say that I had to dig a little bit, to understand how to set it up
but once i set the first one
it was easy
though i would like to note the use of
cd
in your start command is not entirely proper practice, nx would have a way to start a specfic app in your nx monorepo, you shouldn't have to use cd
for anythingyou mean the
build:frontend
and stuff?commands like that yeah,
start:frontend
but instead of building it runs the build of the frontend, without the use of cd
So instead of making 4 projects I could use 1?
I wanted that at start, but couldn't understand it from the documentation
no thats not quite what im getting at, if your nx repo has 4 apps in it, then you need 4 railway services
im just talking about how you should use the proper commands to run the apps in your nx monorepo, using
cd
(while it wont hurt anything) is not a proper solution to run one of the apps in your repo
nx would have a proper method to run a specfic app within the nx monorepo
that doesnt involve cd
at allI guess you are talking about this
I think I tried it at first without anything in the build command
but it didn't work
sorry, i think you are severely misunderstanding me
but i dont know how i could clarify further, and your deployment works, so i will leave it at that
I don't quite understand, because I didn't touch any configuration or anything
so I am not sure what you are talking
but it works, so anyway, if I have any problems in the future 🙂