Backend pages show 404 on Railway but work fine in localhost
Anonymous
TRIALOP

2 years ago

I have different routes I am trying to access but only the first works /api/agents and every other responds 404. All the routes work locally… Not sure what I am doing wrong
project ID: fafdc920-100d-4935-92ce-2d39b2727364

67 Replies

Anonymous
TRIALOP

2 years ago

ValidationError: The 'X-Forwarded-For' header is set but the Express 'trust proxy' setting is false (default). This could indicate a misconfiguration which would prevent express-rate-limit from accurately identifying users. See https://express-rate-limit.github.io/ERRERLUNEXPECTEDXFORWARDED_FOR/ for more information.

at Object.xForwardedForHeader (file:///app/node_modules/express-rate-limit/dist/index.mjs:138:13)

at wrappedValidations. as xForwardedForHeader

at Object.keyGenerator (file:///app/node_modules/express-rate-limit/dist/index.mjs:551:20)

at file:///app/node_modules/express-rate-limit/dist/index.mjs:601:32

at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

at async file:///app/node_modules/express-rate-limit/dist/index.mjs:583:5 {

code: 'ERRERLUNEXPECTEDXFORWARDED_FOR',

help: 'https://express-rate-limit.github.io/ERRERLUNEXPECTEDXFORWARDED_FOR/';

}

::ffff:192.168.0.4 - - [08/Mar/2024:02:59:34 +0000] "GET /api/comments HTTP/1.1" 404 14 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36"
this is the error in the log


brody
EMPLOYEE

2 years ago

you are running behind a proxy though, so you would want to trust the proxy headers


Anonymous
TRIALOP

2 years ago

It doesnt seem to affect it

1215504651475091500


brody
EMPLOYEE

2 years ago

send your domain so i can test?



brody
EMPLOYEE

2 years ago

post or get?


Anonymous
TRIALOP

2 years ago

the default get is doing a select query to mysql for each route


brody
EMPLOYEE

2 years ago

i indeed get 404


brody
EMPLOYEE

2 years ago

what are the differences between your local environment and railway?
there are so many factors at play, different node versions, different build and start commands, committing your dist folder, etc, etc.
can you think of anything?


Anonymous
TRIALOP

2 years ago

not off the top of my head but I can keep looking into that. Although, can you explain why agents and its routes would work? Including say /api/agents/5 but nothing else below it?


brody
EMPLOYEE

2 years ago

i cant, as im not a js dev. so the best advice i can give would be to get the environment on railway as close to your local environment as possible.


brody
EMPLOYEE

2 years ago

what version of node are you running locally?
what version of node is railway running?


Anonymous
TRIALOP

2 years ago

locally i am using v18.18.0 as for railway, I do not know how to check


Anonymous
TRIALOP

2 years ago

its my first time deploying on here


brody
EMPLOYEE

2 years ago

check the build table at the top of the build logs


Anonymous
TRIALOP

2 years ago

this is what i see

1215510767378501600


brody
EMPLOYEE

2 years ago

thats most certainly not the build logs lol


Anonymous
TRIALOP

2 years ago

whoops


Anonymous
TRIALOP

2 years ago

1215511107834347500


Anonymous
TRIALOP

2 years ago

is this what you meant


brody
EMPLOYEE

2 years ago

yep


brody
EMPLOYEE

2 years ago

is this a js or ts project?


Anonymous
TRIALOP

2 years ago

js


brody
EMPLOYEE

2 years ago

could you share your repo


Anonymous
TRIALOP

2 years ago

can you give me your github username, the repo is private and I forked it from my teamate so I will invite you as a reader


brody
EMPLOYEE

2 years ago

brody192


Anonymous
TRIALOP

2 years ago

Ok i invited you


Anonymous
TRIALOP

2 years ago

I only made the changes in branch which is what railway is deploying from


brody
EMPLOYEE

2 years ago

what branch would that be


Anonymous
TRIALOP

2 years ago

url-extension


brody
EMPLOYEE

2 years ago

how are you sure thats what railway is deploying from


Anonymous
TRIALOP

2 years ago

I was assuming this meant that

1215516343110074400


brody
EMPLOYEE

2 years ago

doesnt look like you have deployed that change though?


brody
EMPLOYEE

2 years ago

its blue


Anonymous
TRIALOP

2 years ago

I redeployed earlier but I will do it again


Anonymous
TRIALOP

2 years ago

Did you mean this is blue?

1215517046633140200


brody
EMPLOYEE

2 years ago

well yes that is also blue, but your branch is also blue


brody
EMPLOYEE

2 years ago

aka you havent saved (deployed the changes) and if the branch is blue that means thats not the actual branch in use


Anonymous
TRIALOP

2 years ago

I merged the branch to main on github now, so in order for the blue to go away on railway do I just redeploy?


brody
EMPLOYEE

2 years ago

click the deploy button


Anonymous
TRIALOP

2 years ago

its still just the same color and deploy log still shows this error

ValidationError: The 'X-Forwarded-For' header is set but the Express 'trust proxy' setting is false (default). This could indicate a misconfiguration which would prevent express-rate-limit from accurately identifying users. See https://express-rate-limit.github.io/ERRERLUNEXPECTEDXFORWARDED_FOR/ for more information.

at Object.xForwardedForHeader (file:///app/node_modules/express-rate-limit/dist/index.mjs:138:13)

at wrappedValidations. as xForwardedForHeader

at Object.keyGenerator (file:///app/node_modules/express-rate-limit/dist/index.mjs:551:20)

at file:///app/node_modules/express-rate-limit/dist/index.mjs:601:32

at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

at async file:///app/node_modules/express-rate-limit/dist/index.mjs:583:5 {

code: 'ERRERLUNEXPECTEDXFORWARDED_FOR',

help: 'https://express-rate-limit.github.io/ERRERLUNEXPECTEDXFORWARDED_FOR/';

}


Anonymous
TRIALOP

2 years ago

1215520161033879600


brody
EMPLOYEE

2 years ago

please deploy the changes


Anonymous
TRIALOP

2 years ago

Sorry I think I am confused, is redeploy not the correct button and if so I cant seem to find a "deploy button"


brody
EMPLOYEE

2 years ago

big blue deploy button


Anonymous
TRIALOP

2 years ago

I must be blind I am not seeing a big blue deploy button

1215522216200904700
1215522216578523100
1215522216960065500
1215522217283031000
1215522217753059300
1215522218684059600


brody
EMPLOYEE

2 years ago

have you tried a hard refresh


Anonymous
TRIALOP

2 years ago

i tried ctrl + shit + r, ctrl + f5, ctrl + r


brody
EMPLOYEE

2 years ago

try in an incognito window


Anonymous
TRIALOP

2 years ago

JFC


Anonymous
TRIALOP

2 years ago

that was so frustrating


Anonymous
TRIALOP

2 years ago

thank you so much


brody
EMPLOYEE

2 years ago

what's JFC


Anonymous
TRIALOP

2 years ago

jesus f christ


Anonymous
TRIALOP

2 years ago

lmao


brody
EMPLOYEE

2 years ago

I assume you saw the deploy button in incognito?


Anonymous
TRIALOP

2 years ago

why would the button not pop only in incognito


Anonymous
TRIALOP

2 years ago

yeah it was a little button at the top


brody
EMPLOYEE

2 years ago

some kind of extension interference?


Anonymous
TRIALOP

2 years ago

well, the routes seem to be working now


brody
EMPLOYEE

2 years ago

awesome


Anonymous
TRIALOP

2 years ago

sorry to waste your time but you helped tremendously


Anonymous
TRIALOP

2 years ago

ill definitely be buying you some coffee


brody
EMPLOYEE

2 years ago

no time wasted, happy to help


Anonymous
TRIALOP

2 years ago

seriously thanks man youre a gem!


brody
EMPLOYEE

2 years ago

no problem 🙂


brody
EMPLOYEE

2 years ago

thank you for the trains!!


Loading...