is there any way to handle Set-Cookie response in Nuxt3 using ssr: false.
I am sending a Request to a PHP Server and I am getting a Set-Cookie response with the session Cookie.
let f = new FormData();
f.append("s[Username]", username);
f.append("s[Password]", password);
// fetch data from api and set response cookie
const response: any = await $fetch(url, {
method: 'POST',
body: f,
});
But I can`t access the cookie inside the response.
CodePudding user response:
You should see your cookie in the dev tools of your browser (Storage tab on Firefox under Cookies, Application tab on Chrome under Cookies section). After you confirm that it's there, you can access it in Nuxt 3 with useCookie()
composable. Here's an example:
const cookie = useCookie('your-cookie-name');
cookie.value // returns cookie value
cookie.value = null // deletes the cookie
CodePudding user response:
The solution is simple. The issue was caused by the localhost development. The domain was not the same. I did a build, and it worked on the server.