405 Method Not Allowed
thebarndog
HOBBYOP

a year ago

Hello there! Recently migrated to Railway and loving the service so far but unforuntatley we've hit a blocker that we can't seem to get past. Every time I make a rest request to my connected backend service, I'm receiving a

Failed to load resource: the server responded with a status of 405 ()

My setup: NodeJS backend
Frontend: Vite + React application running using Caddy

I did a search through the discord and it seems like this is an issue a lot of people have initially so I made sure that the API url is set to ${{my-backend.RAILWAYPUBLICDOMAIN}} since it's all served client side. But the error persists. On the backend side, I set the allowed origins to a JSON array

[""http://localhost:5173", "dolly-frontend.railway.internal", "staging.dollycard.com"]

(the last entry being the RAILWAYPUBLICDOMAIN for my frontend).

Project ID: 3398ae78-39ba-4118-bd8e-62f59919d981

What's strange is I can't replicate these errors via insomnia or postman, I'm getting 401s locally even though the routes I'm testing against are unprotected.

I should mention as well that when the 405 error message prints in the console, what I see for the full url is https://staging.dollycard.com/api.staging.dollycard.com/users, is that expected?

Solved

14 Replies

a year ago

I think these docs will help you -


thebarndog
HOBBYOP

a year ago

It happens over https unfortunately


a year ago

your API url is set to a value without https:// though


thebarndog
HOBBYOP

a year ago

oh interesting, I'm just using the reference variables but you think it has to be https://${{ RAILWAY_PUBLIC_DOMAIN }}?


a year ago

RAILWAYPUBLICDOMAIN doesn't include https://


thebarndog
HOBBYOP

a year ago

Gotcha, seemed to to get rid of the 405s at least! Thanks Brody!


a year ago

no problem!


thebarndog
HOBBYOP

a year ago

Still some weird 500 and 401s that aren't happening on localhost but will continue debugging 🙂 One issue at a time


a year ago

sounds good!


thebarndog
HOBBYOP

a year ago

Oh do I need https on the backend for the cors origins as well?


a year ago

not sure, you'd want to reference the docs for the cors middleware you are using


thebarndog
HOBBYOP

a year ago

Think I realized what it was anyway, inputted an incorrect secret variable from AWS cognito so it was yelling at me. But seriously thank you for helping me get past the 405s, was banging my head against the wall with that. We here all love railway so far, it's been so great


a year ago

glad I could help!


a year ago

!s


Status changed to Solved brody about 1 year ago


Loading...