Backend pages show 404 on Railway but work fine in localhost
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
55 Replies
Project ID:
fafdc920-100d-4935-92ce-2d39b2727364
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/ERR_ERL_UNEXPECTED_X_FORWARDED_FOR/ for more information.
at Object.xForwardedForHeader (file:///app/node_modules/express-rate-limit/dist/index.mjs:138:13)
at wrappedValidations.<computed> [as xForwardedForHeader] (file:///app/node_modules/express-rate-limit/dist/index.mjs:296:22)
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: 'ERR_ERL_UNEXPECTED_X_FORWARDED_FOR',
help: 'https://express-rate-limit.github.io/ERR_ERL_UNEXPECTED_X_FORWARDED_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
you are running behind a proxy though, so you would want to trust the proxy headers
It doesnt seem to affect it
send your domain so i can test?
post or get?
the default get is doing a select query to mysql for each route
i indeed get 404
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?
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?
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.
what version of node are you running locally?
what version of node is railway running?
locally i am using v18.18.0 as for railway, I do not know how to check
its my first time deploying on here
check the build table at the top of the build logs
this is what i see
thats most certainly not the build logs lol
whoops
is this what you meant
yep
is this a js or ts project?
js
could you share your repo
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
brody192
Ok i invited you
I only made the changes in branch which is what railway is deploying from
what branch would that be
url-extension
how are you sure thats what railway is deploying from
I was assuming this meant that
doesnt look like you have deployed that change though?
its blue
I redeployed earlier but I will do it again
Did you mean this is blue?
well yes that is also blue, but your branch is also blue
aka you havent saved (deployed the changes) and if the branch is blue that means thats not the actual branch in use
I merged the branch to main on github now, so in order for the blue to go away on railway do I just redeploy?
click the deploy button
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/ERR_ERL_UNEXPECTED_X_FORWARDED_FOR/ for more information.
at Object.xForwardedForHeader (file:///app/node_modules/express-rate-limit/dist/index.mjs:138:13)
at wrappedValidations.<computed> [as xForwardedForHeader] (file:///app/node_modules/express-rate-limit/dist/index.mjs:296:22)
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: 'ERR_ERL_UNEXPECTED_X_FORWARDED_FOR',
help: 'https://express-rate-limit.github.io/ERR_ERL_UNEXPECTED_X_FORWARDED_FOR/';
}
please deploy the changes
Sorry I think I am confused, is redeploy not the correct button and if so I cant seem to find a "deploy button"
big blue deploy button
I must be blind I am not seeing a big blue deploy button
have you tried a hard refresh
i tried ctrl + shit + r, ctrl + f5, ctrl + r
try in an incognito window
JFC
that was so frustrating
thank you so much
what's JFC
jesus f christ
lmao
I assume you saw the deploy button in incognito?
why would the button not pop only in incognito
yeah it was a little button at the top
some kind of extension interference?
well, the routes seem to be working now
awesome
sorry to waste your time but you helped tremendously
ill definitely be buying you some coffee
no time wasted, happy to help
seriously thanks man youre a gem!
no problem 🙂
thank you for the trains!!