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