-
-
Notifications
You must be signed in to change notification settings - Fork 240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
422 Error with @jwt_required() in Flask App Deployed on VPS with Nginx #563
Comments
Hrm... this sounds vaguely familiar, but it's been a very long time since I've done any nginx configuration, and I'm not seeing anything specific off hand. Some questions to help troubleshoot this further:
|
Hi Lily, I hope you're doing well, Thank you for your support! the Errors says: 422 Unprocessable Entity, I am using only Flask development server (jsut for test) when I remove @jwt_required() decorator the request works fine and print the header normally! The same application works as expected (even with @jwt_required()) when deployed on Heroku. @app.route('/upload', methods=['POST']) here is Nginx config: server {
} |
@mhammadzahi , you need to add proper logging in your application to troubleshoot issues, without it we can only guess.
If you can pinpoint the exact line of code that triggers the error, that would be a start. I don't know if your app runs as a service, but maybe try to run your app manually over SSH and look at console messages. |
I got the same issue as @mhammadzahi comments. I have an api deployed on google app engine, it was working great with version 4.6.0, but after the update to version 4.7.1 I only get 422 response. Currently, my solution was to return to version 4.6.0 |
You shouldn't be using the flask dev server like that. Per their docs
Here is the documentation for doing that provided by flask:
RE the error message, I need the actual message returned by the response of the I think if you follow along with the official flask deployment instructions, and use a wsgi server configured with nginx, that will likely fix your issues. |
@menyDev That's not going to be the same issue as this ticket. The only difference between 4.6.0 and 4.7.1 is we added the (see: #561) |
@vimalloc, You should not close it, I did not find the solution yet! your library is not working |
That is not correct, this library is in fact working correctly, it’s your nginx setup that has an issue. Please see my above comment for further steps you can take to resolve the issue. If you are unable to resolve the issue using the above steps, then please provide the details of what you tried, as well as the additional details I had asked for. |
Hi everyone,
I'm facing an issue while deploying my Flask application on a VPS server with Nginx. The app works fine when tested locally and also when hosted on Heroku. However, when deployed on my VPS, any route protected by @jwt_required() throws a 422 error.
Server Setup: Ubuntu VPS Nginx as a reverse proxy Flask Development Server to run the Flask app (just for test) Flask-JWT-Extended for JWT authentication
What Works: All API routes without the @jwt_required() decorator work perfectly. The same application works as expected (even with @jwt_required()) when deployed on Heroku.
What Fails: Any route using the @jwt_required() decorator on the VPS setup returns a 422 error. Removing @jwt_required() allows the routes to work normally.
I suspect it might have something to do with Nginx configurations, but I can’t figure out what. Could it be related to how headers or JSON bodies are being handled by the server? Any suggestions or troubleshooting tips would be greatly appreciated! Thanks in advance!
The text was updated successfully, but these errors were encountered: