Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
like image 722
Vova Bes Avatar asked Sep 01 '20 13:09

Vova Bes


1 Answers

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

like image 168
coma Avatar answered Sep 30 '22 02:09

coma