I'm trying to set three cookies: access_token, refresh_token and logged_in from server side. I deployed FastAPI backend on heroku and react.js frontend on netlify. Of course, I set correctly cookies parameters with CORS policy on backend side. In localhost everything was fine, but after deploy frontend doesn't set cookies from axios request(withCredentials value is true). I don't see any cookies in Chrome application/Cookies and Firefox.
Early, I though that problem is on backend side, but when I used fetch request with credentials - everything was fine. Somebody has idea how to fix this problem?
my response cookies in FastAPI app
response.set_cookie('access_token', access_token, ACCESS_TOKEN_EXPIRES_IN * 60,
ACCESS_TOKEN_EXPIRES_IN * 60, '/', None, True, True, samesite='none')
response.set_cookie('refresh_token', refresh_token,
REFRESH_TOKEN_EXPIRES_IN * 60, REFRESH_TOKEN_EXPIRES_IN * 60, '/', None, True, True, 'none')
response.set_cookie('logged_in', 'True', ACCESS_TOKEN_EXPIRES_IN * 60,
ACCESS_TOKEN_EXPIRES_IN * 60, '/', None, True,True, 'none')
my example requests in react app
const axi = async () => {
await axios({
url: 'https://example.com/auth/login',
method: "post",
data: {"email": "exam@ple.eu", "password": "stringst"},
withCredentials: true,
headers: {
"Content-Type": "application/json",
}
})
.then((res) => {
console.log(res)
})
}
const fet = async () => {
await fetch('https://example.com/auth/login', {
method: 'POST',
// mode: 'cors',
credentials: 'include',
body: {"email": "exam@ple.eu", "password": "stringst"},
headers: {
"Content-Type": "application/json",
}
}).then(res => {
console.log(res)
})
}