Replies: 3 comments
-
Hmm, I'm not sure I understand clearly what you want to achieve. Could you create a small self-contained app that shows the behavior? Also, I would suggest you start your tests with plain Uvicorn, without Nginx. That way you will be able to see if the error is generated on the FastAPI side or on the side of Nginx configs. |
Beta Was this translation helpful? Give feedback.
-
Actually, turns out it was an issue with uvicorn. For some reason it just doesn't send any headers when you change status codes to any http error. Also tried with gunicorn and runs with no problems at all. 🤔 |
Beta Was this translation helpful? Give feedback.
-
Thanks for reporting back and closing the issue 👍 |
Beta Was this translation helpful? Give feedback.
-
First check
Description
So, I've set up reverse proxy through nginx and added headers in there, I also configured that CORS middleware too and the problem is, when my
verify_token
middleware triggers and if it's response status_code is 400 or 401 or any other 4XX error - the client doesn't receive CORS headers at all.Is it possible to be a bug of FastAPI or is it something wrong with the configuration?
I searched about it and I honestly couldn't find any information on that problem... What's interesting is that Postman still shows the CORS header but JavaScript says there are none (in case if I send the error status code).
Beta Was this translation helpful? Give feedback.
All reactions