In Vite res.cookie is not set the cookie
I don't know why.
in this code I am send cookie in res but it is not set in cooke with Vite react
This is fetching the login URL console.log of line no. 31 in the image In network res showing Set-Cookie: token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY0MmVkNjk2MTkwODUxZWFjZjRjZWNmNCIsImlhdCI6MTY4MTU5NzAyNSwiZXhwIjoxNjgyMDI5MDI1fQ.JAA_1TDtrBry3MhuAXGi0DrtmVQ5uAPMoaIavOgsPcc; Path=/; Expires=Sat, 15 Apr 2023 22:17:35 GMT; HttpOnly
but this cookie is not showing in application cookie enter image description here
res is coming perfectly
Code of send cookie with token
`const sendToken = async (user, statusCode, res) => {
const token = await user.getJwtToken();
const option = {
httpOnly: true,
expires: new Date(
new Date(Date.now() + 30000)
),
};
console.log(
process.env.COOKIE_EXPIRE,
option,
);
return res.status(statusCode).cookie("token", token, option).json({
success: true,
user,
token,
});
};`
export default sendToken;
**Code of fetch login on vite React**
`export const loginUser = createAsyncThunk(
"loginUser",
async (args, { rejectWithValue }) => {
try {
const config = {
header: { "Content-Type": "application/json" },
};
let url = `${import.meta.env.VITE_REACT_APP_BASE_URL}/dashboard_login`;
const user = await axios.post(url, args, config);
console.log(user);
return await user.data;
} catch (err) {
console.log(err);
return await err.response.data;
}
}
);`