Skip to content
This repository has been archived by the owner on Mar 26, 2024. It is now read-only.

fix: cookies problem fixed #76

Merged
merged 1 commit into from
Mar 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions client/src/features/authSlice.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ const authSlice = createSlice({
state.isSuccess = true;
state.user = action.payload.user;
localStorage.setItem("user", JSON.stringify(action.payload.user));
Cookies.set("token", action.payload.token, { expires: 3 });
Cookies.set("token", action.payload.token, {
secure: true,
sameSite: "Lax",
path: '/',
expires: 3,
});
})
.addCase(login.rejected, (state, action) => {
state.isLoading = false;
Expand All @@ -52,7 +57,12 @@ const authSlice = createSlice({
state.isSuccess = true;
state.user = action.payload.user;
localStorage.setItem("user", JSON.stringify(action.payload.user));
Cookies.set("token", action.payload.token, { expires: 3 });
Cookies.set("token", action.payload.token, {
secure: true,
sameSite: "Lax",
path: '/',
expires: 3,
});
})
.addCase(signUp.rejected, (state, action) => {
state.isLoading = false;
Expand Down