Reputation: 490
I'm trying to set a cookie from a Flask server on an ajax request from a react app. I made an easy test case and even then, the cookie is sent in the response, but isn't set in the browser
Flask:
@app.route('/is_alive', methods = ['POST'])
def alive():
resp = app.make_response("There should be a cookie")
resp.set_cookie("testing", 'testing')
return resp
Javascript:
static isAlivePost() {
return new Promise(resolve => {
let options = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
},
credentials: 'same-origin',
body: JSON.stringify({
firstParam: 'true'
})
}
fetch(endpoints.MOCK_API + 'is_alive', options)
.then(response => {
resolve(response.text());
}).then(function(data) {
resolve(data);
})
.catch(e => {
reject(e);
});
});
}
Upvotes: 1
Views: 1487