Skip to content Skip to sidebar Skip to footer

Flask-cors Wrapper Not Working When Jwt Auth Wrapper Is Applied.

I'm trying to build a api site using Flask, and I am using Flask-jwt to provide token authorization. The authorizaiton works fine if I do CORS in Apache ( using mod_headers to add

Solution 1:

After struggling for many hours, I finally found the problem. Hope it helps others who encouter the same problem.
Just need to include Authorization in "headers" argument (which sets the Access-Control-Allow-Headers field) when authentication is needed.
Like this

@app.route('/protected/place') 
@cross_origin(headers=['Content-Type','Authorization']) # Send Access-Control-Allow-Headers 
@jwt_required() 
def my_view_func(): 
    do something

Post a Comment for "Flask-cors Wrapper Not Working When Jwt Auth Wrapper Is Applied."