Skip to content

Strange behavior when call is made from ajax, other domain #359

@KathRains

Description

@KathRains

Hi!
I have a project where front-end(React) and back-end(Flask) are working on different domains.

I added the following test end-point:

@test _api.route('/test')
class test_route(Resource):
    @jwt_required
    def get(self):
        return jsonify({'result': True})

It's working properly if I provide a valid access token (in header, as I can't use it in the cookie).

But if it's not provided, or it's wrong I can't make the following handler work right:

@jwt.unauthorized_loader
def unauthorized_loader_handler(message):
    return jsonify({
            "description": "Access token not found!",
            "error": "unauthorized_loader"
        }, 401)

in a case of unauthorized loader and get into this handler but right after the exception is thrown:

Server-side ERROR: 'Response' object has no attribute 'get'

I just want it to return status 401 to the front-end.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions