#No internet inside the Docker?

123 messages · Page 1 of 1 (latest)

oblique karma
#

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!

wintry ibexBOT
#

Project ID: 4246fe3e-d361-4321-a202-34c1691a3e3c

oblique karma
#

4246fe3e-d361-4321-a202-34c1691a3e3c

knotty acorn
#

show your errors and the exact urls you are trying to use that return 404

oblique karma
#

How am I supposed to copy the errors? 🤣

knotty acorn
#

copy paste, screenshots, etc

oblique karma
#

I doesn't fit the entire screen

#

and it's not copyable

knotty acorn
oblique karma
#

This is postman from my computer (works)

knotty acorn
#

okay now please show me he code that makes this same request

oblique karma
#

This it the instance of axios

#

This is the code, not sure it will tell you a lot

knotty acorn
#

okay and let's see what you have set for that environment variable in the railway service please

oblique karma
#

Yup, one moment

knotty acorn
#

side question, are you building with a dockerfile or nixpacks?

oblique karma
#
NEXT_PUBLIC_BACKEND_PATH=https://api.clickvote.dev
NEXT_PUBLIC_WEBSOCKETS_URL=socket.clickvote.dev
NIXPACKS_NX_APP_NAME=frontend
#

nixpacks

knotty acorn
#

have you done a sanity check console log for that environment variable right before you initialise the axios instance?

oblique karma
#

You can see inside the 404 error that it write the path

#

so it works

knotty acorn
#

what version of node are you using locally

oblique karma
#

in the baseUrl

#

v18.9.1

knotty acorn
#

what version is Railway using

oblique karma
#

Would it be possible that the DNS is not yet updated inside the docker files?

#

One moment

#

I will check

knotty acorn
#

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

oblique karma
#

Is there any way to ssh into the containers?

knotty acorn
#

nope

oblique karma
#

Is there any reason the I won't be able from inside the container to turn into a public URL?

knotty acorn
#

sorry I didn't quite understand that

#

but I assume the next app works locally?

oblique karma
#

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

knotty acorn
#

can I ask why you don't want to use the private domain?

oblique karma
#

every person can use their on configuration

#

So I don't want to force this logic

knotty acorn
#

gotcha

#

so are you calling a separate railway service from your next backend? or are calling yourself in a hairpin configuration

novel elm
#

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/

oblique karma
#

A seperate railway service

knotty acorn
#

this test makes the request inside of the railway service

#

so same type of thing you get a 404 for

oblique karma
knotty acorn
#

I of course get 401 since I'm unauthorized, but it's not a 404

oblique karma
#

Yes 401 is perfect

#

but 404 is weird

knotty acorn
#

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

oblique karma
#

You have probably heard it a million of times, but it works locally 🤣

knotty acorn
#

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)

oblique karma
#

I just interesting because I also don't see any log of errors

#

or anything in the backend

novel elm
#

try to plug a nestjs logger to log every request

oblique karma
#

I will try to connect morgen

#

I doubt it will work

#

but will try it now

knotty acorn
#

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

oblique karma
#

But it's a different network no?

#

I wonder if you will get the same from the same network

knotty acorn
#

that doesn't matter, if this was a network issue you would not just be getting a 404

novel elm
#

btw, you could probably just log the response you get from the server, nestjs returns the path for you

knotty acorn
#

yep thalles couldn't be more right, logging!!! log everything

#

never underestimate how useful debug logs can be

oblique karma
#

I added morgan

#

Will test it now 🙂

knotty acorn
#

might also be worth adding debug logs for the incoming requests on the backend as well

oblique karma
#

Yup it's what I thought, it's not getting into the server

knotty acorn
#

what are you hitting that is returning the 404 then?

novel elm
#

i've thought that you're probably hitting yourself?

#

as i said, log the response from the server

#

you'll get your answer

oblique karma
#

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

#

Which is the nextjs app

novel elm
oblique karma
novel elm
#

that's why i moved away from axios

#

fetch ftw

oblique karma
#

and in the response headers it has
NextJs headers

oblique karma
#

Yup, Axios bug. Sorry for wasting your time 🙏🏻

knotty acorn
#

no worries at all, no time was wasted

oblique karma
#

Railways rocks!
It was so easy to set the NX monorepo 🚀

knotty acorn
#

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

oblique karma
#

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

knotty acorn
#

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

oblique karma
#

you mean the build:frontend and stuff?

knotty acorn
#

commands like that yeah, start:frontend but instead of building it runs the build of the frontend, without the use of cd

oblique karma
#

So instead of making 4 projects I could use 1?

#

I wanted that at start, but couldn't understand it from the documentation

knotty acorn
#

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

oblique karma
#

I guess you are talking about this

#

I think I tried it at first without anything in the build command

#

but it didn't work

knotty acorn
#

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

oblique karma
#

I don't quite understand, because I didn't touch any configuration or anything

#

so I am not sure what you are talking