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
Percy
Percy13mo ago
Project ID: 4246fe3e-d361-4321-a202-34c1691a3e3c
Nevo David
Nevo David13mo ago
4246fe3e-d361-4321-a202-34c1691a3e3c
Brody
Brody13mo ago
show your errors and the exact urls you are trying to use that return 404
Nevo David
Nevo David13mo ago
How am I supposed to copy the errors? 🤣
Brody
Brody13mo ago
copy paste, screenshots, etc
Nevo David
Nevo David13mo ago
I doesn't fit the entire screen
No description
Nevo David
Nevo David13mo ago
and it's not copyable
Brody
Brody13mo ago
it absolutely is copy-able, but use this https://bookmarklets.up.railway.app/log-downloader/
Nevo David
Nevo David13mo ago
This is postman from my computer (works)
No description
Brody
Brody13mo ago
okay now please show me he code that makes this same request
Nevo David
Nevo David13mo ago
This it the instance of axios
No description
Nevo David
Nevo David13mo ago
This is the code, not sure it will tell you a lot
No description
Brody
Brody13mo ago
okay and let's see what you have set for that environment variable in the railway service please
Nevo David
Nevo David13mo ago
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
Brody
Brody13mo ago
side question, are you building with a dockerfile or nixpacks?
Nevo David
Nevo David13mo ago
NEXT_PUBLIC_BACKEND_PATH=https://api.clickvote.dev
NEXT_PUBLIC_WEBSOCKETS_URL=socket.clickvote.dev
NIXPACKS_NX_APP_NAME=frontend
NEXT_PUBLIC_BACKEND_PATH=https://api.clickvote.dev
NEXT_PUBLIC_WEBSOCKETS_URL=socket.clickvote.dev
NIXPACKS_NX_APP_NAME=frontend
nixpacks
Brody
Brody13mo ago
have you done a sanity check console log for that environment variable right before you initialise the axios instance?
Nevo David
Nevo David13mo ago
You can see inside the 404 error that it write the path so it works
Nevo David
Nevo David13mo ago
No description
Brody
Brody13mo ago
what version of node are you using locally
Nevo David
Nevo David13mo ago
in the baseUrl v18.9.1
Brody
Brody13mo ago
what version is Railway using
Nevo David
Nevo David13mo ago
Would it be possible that the DNS is not yet updated inside the docker files? One moment I will check
Nevo David
Nevo David13mo ago
No description
Brody
Brody13mo ago
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
Nevo David
Nevo David13mo ago
Is there any way to ssh into the containers?
Brody
Brody13mo ago
nope
Nevo David
Nevo David13mo ago
Is there any reason the I won't be able from inside the container to turn into a public URL?
Brody
Brody13mo ago
sorry I didn't quite understand that but I assume the next app works locally?
Nevo David
Nevo David13mo ago
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
Brody
Brody13mo ago
can I ask why you don't want to use the private domain?
Nevo David
Nevo David13mo ago
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.
Nevo David
Nevo David13mo ago
every person can use their on configuration So I don't want to force this logic
Brody
Brody13mo ago
gotcha so are you calling a separate railway service from your next backend? or are calling yourself in a hairpin configuration
ThallesComH
ThallesComH13mo ago
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/
Nevo David
Nevo David13mo ago
Nope 🙂 It says responseUrl: 'https://api.clickvote.dev/users/self', A seperate railway service
Brody
Brody13mo ago
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
Nevo David
Nevo David13mo ago
No description
Brody
Brody13mo ago
I of course get 401 since I'm unauthorized, but it's not a 404
Nevo David
Nevo David13mo ago
Yes 401 is perfect but 404 is weird
Brody
Brody13mo ago
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
Nevo David
Nevo David13mo ago
You have probably heard it a million of times, but it works locally 🤣
Brody
Brody13mo ago
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)
Nevo David
Nevo David13mo ago
I just interesting because I also don't see any log of errors or anything in the backend
ThallesComH
ThallesComH13mo ago
try to plug a nestjs logger to log every request
Nevo David
Nevo David13mo ago
I will try to connect morgen I doubt it will work but will try it now
Brody
Brody13mo ago
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
Nevo David
Nevo David13mo ago
But it's a different network no? I wonder if you will get the same from the same network
Brody
Brody13mo ago
that doesn't matter, if this was a network issue you would not just be getting a 404
ThallesComH
ThallesComH13mo ago
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
Brody
Brody13mo ago
yep thalles couldn't be more right, logging!!! log everything never underestimate how useful debug logs can be
Nevo David
Nevo David13mo ago
I added morgan Will test it now 🙂
Brody
Brody13mo ago
might also be worth adding debug logs for the incoming requests on the backend as well
Nevo David
Nevo David13mo ago
Yup it's what I thought, it's not getting into the server
Brody
Brody13mo ago
what are you hitting that is returning the 404 then?
ThallesComH
ThallesComH13mo ago
i've thought that you're probably hitting yourself? as i said, log the response from the server you'll get your answer
Nevo David
Nevo David13mo ago
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
ThallesComH
ThallesComH13mo ago
it's probably something that you're doing here, just get the axiosInstance and do the request to see if that works
Nevo David
Nevo David13mo ago
but it's weird because in the request headers it has responseUrl: 'https://api.clickvote.dev/users/self';,
ThallesComH
ThallesComH13mo ago
that's why i moved away from axios fetch ftw
Nevo David
Nevo David13mo ago
and in the response headers it has NextJs headers Yup, Axios bug. Sorry for wasting your time 🙏🏻
Brody
Brody13mo ago
no worries at all, no time was wasted
Nevo David
Nevo David13mo ago
Railways rocks! It was so easy to set the NX monorepo 🚀
Brody
Brody13mo ago
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
Nevo David
Nevo David13mo ago
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
Brody
Brody13mo ago
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 anything
Nevo David
Nevo David13mo ago
you mean the build:frontend and stuff?
Brody
Brody13mo ago
commands like that yeah, start:frontend but instead of building it runs the build of the frontend, without the use of cd
Nevo David
Nevo David13mo ago
So instead of making 4 projects I could use 1? I wanted that at start, but couldn't understand it from the documentation
Brody
Brody13mo ago
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 all
Nevo David
Nevo David13mo ago
I guess you are talking about this
No description
Nevo David
Nevo David13mo ago
I think I tried it at first without anything in the build command but it didn't work
Brody
Brody13mo ago
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
Nevo David
Nevo David13mo ago
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 🙂
Want results from more Discord servers?
Add your server