Closed ethan0905 closed 1 year ago
Tried to use packages to make the read of cookies easier (cookies-js), but still, my token var remains undefined.
import Cookies from 'js-cookie';
// [...]
const token = Cookies.get('token');
After a lot of researches, the cookie was well stored, but the parameters were blocking the cookie retrieve aspect on client side (for security concerns).
Check if the cookie is HttpOnly: If the cookie is set with the HttpOnly flag, it cannot be accessed from client-side JavaScript. In this case, you will need to find a way to retrieve the cookie on the server-side.
async createCookies(@Res() res: Response, token: any) {
console.log("Creating cookies with: [" + token.access_token + "]\n");
const cookies = res.cookie("token", token.access_token,
{
expires: new Date(new Date().getTime() + 60 * 24 * 7 * 1000), // expires in 7 days
// httpOnly: true, // for security
httpOnly: false, // setting it to false allows me retrieve it on the client side
});
}
Hello I have an error when trying to use my cookie informations.
When i try to read content from my backend side,
an error occure. My token is considered empty or undefined, even if I know that it not the case.
If you already have manipulated cookies or have any idea, feel free to answer.