5 months ago
Github repository:
https://github.com/hobbie71/MakeCode-Arcade-Sprite-Generator
Project ID:
3a021bd1-db69-4e85-9cdc-24f00ad39bde
Hey!
So I have a react frontend. just a static site that's working.
And I have a FastAPI backend.
Every time I go to my frontend URL, go through my app, and do something that calls an API from my backend, I get this error:
...has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
To debug this, I went ahead and added this to my ENV variables
CORS_ORIGINS="["*"]"
and somehow, I still get this errors. I'm assuming it's something wrong with my backend code? When I run this in a dev envornment, it works fine even when adding specific urls like this:
CORS_ORIGINS="["http://localhost:3000", "http://localhost:5173"]"
So, I'm not sure why I'm getting this error. I would appreciate any help.
Even debugging tips or possible causes of the issue would be a huge help.
I've been at this for too many hours, so I'm going to go to bed.
Thank you for reading this post and taking the time to help me find a solution.
6 Replies
5 months ago
Hey there! We've found the following might help you get unblocked faster:
If you find the answer from one of these, please let us know by solving the thread!
5 months ago
For some reason thats just how railway is, i had the same issues with my Hono backend app
5 months ago
Hey, please make sure you are sending a HTTPS request, not HTTP to your railway backend :)
irazvan2745
For some reason thats just how railway is, i had the same issues with my Hono backend app
5 months ago
Hey irazvan,
So there's no way to fix it?
Railway just isn't compatible with FastAPI and Hono?
luksuz
Hey, please make sure you are sending a HTTPS request, not HTTP to your railway backend :)
5 months ago
Hey Luksuz,
I was sending the request through the generated link for my front-end.
You know the railway.app url.
When I check, it is an HTTPS URL. Also, from the error I get in the console, it shows me the URL which also include HTTPS in the front of the url.
hobbie71
Hey irazvan,So there's no way to fix it?Railway just isn't compatible with FastAPI and Hono?
5 months ago
its just CORS being special and i think railway forces you to not use * in cors
Status changed to Open brody • 5 months ago