Search code examples
vue.jsflaskcookiessamesite

this set-cookie was blocked because it has the samesite=lax


Hello i have flask back end and vue front and i can not set cookie in browser.When I send cookie from flask to vue bruser give me worrning:

This set-cookie was blocked because it has the samesite=lax attribute but come from cross-site response witch was not the response to top-level navigation

Code:

    from flask import Flask, make_response, jsonify
    from flask_cors import CORS


    app = Flask(__name__)
    CORS(app, supports_credentials=True, resources={r"/*": {"origins": "*"}})


    @app.route('/', methods=['GET'])
    def index():
        resp = make_response(jsonify({'message': 'Hello new flask'}))
        resp.set_cookie('key', 'hello', samesite='Strict', secure=True)
        return resp, 200

Solution

  • Try to set the SameSite property to None and use https.