Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

863
Views
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
over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

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

over 4 years ago · Santiago Trujillo Report

0

This works for me (tested using Firefox as Browser). The cookie appears as saved in the browser's dev tool "storage". Even accessing the Flask app at port 5000 sets the cookie in the browser.

Using the flask app just as you described:

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


if __name__ == '__main__':
    app.run()

... and an Vue app using this template to test (using axios to access the Flask app):

<template>
  <div id="app">
    <input type="button" value="test" @click="test"/>

    <p>{{ backend_result }}</p>

  </div>
</template>

<script>
import axios from 'axios';

export default {
  name: 'App',
  data() {
    return {
      backend_result: ''
    }
  },
  methods: {
    test() {
      axios.get(
          'http://localhost:5000/',
          {withCredentials: true}
      ).then(
          result => {
            console.log(result)
            this.backend_result = result.data
          }
      )
    }
  }
}
</script>
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!