Skip to content

Commit

Permalink
fix:secure:true enabled so when testing in local change it
Browse files Browse the repository at this point in the history
  • Loading branch information
jeevan-joji committed Dec 10, 2024
1 parent 28949d8 commit 8afa7fd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
11 changes: 7 additions & 4 deletions backend/controllers/authController.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ export const refreshToken = async (req, res, next) => {
await User.updateOne({ _id: user._id }, { refreshToken: newRefreshToken });

res
.cookie("access_token", newAccessToken, { httpOnly: true, maxAge: 900000,sameSite: 'none', }) // 15 minutes
.cookie("refresh_token", newRefreshToken, { httpOnly: true, maxAge: 604800000 ,sameSite: 'none',}) // 7 days
.cookie("access_token", newAccessToken, { httpOnly: true, maxAge: 900000,sameSite: 'none',secure:true }) // 15 minutes
.cookie("refresh_token", newRefreshToken, { httpOnly: true, maxAge: 604800000 ,sameSite: 'none',secure:true}) // 7 days
.status(200)
.json({ accessToken: newAccessToken });
} catch (error) {
Expand Down Expand Up @@ -89,17 +89,20 @@ export const signIn = async (req, res, next) => {
isAdmin: validUser.isAdmin,
isUser: validUser.isUser,
};
next();


res
.cookie("access_token", accessToken, { httpOnly: true, maxAge: 900000 ,sameSite: 'none',}) // 15 minutes
.cookie("access_token", accessToken, { httpOnly: true, maxAge: 900000 ,sameSite: 'none', secure:true}) // 15 minutes
.cookie("refresh_token", refreshToken, {
httpOnly: true,
maxAge: 604800000,
sameSite: 'none',
secure:true
}) // 7 days
.status(200)
.json(responsePayload);

next();
} catch (error) {
next(error);
}
Expand Down
5 changes: 4 additions & 1 deletion client/src/pages/user/Vehicles.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const onVehicleDetail = async (id, dispatch, navigate) => {
headers: {
"Content-Type": "application/json",
},
credentials:'include',
body: JSON.stringify({ id }),
});
const data = await res.json();
Expand Down Expand Up @@ -56,7 +57,9 @@ const Vehicles = () => {
const fetchData = async () => {
console.log(BASE_URL)
try {
const res = await fetch(`${BASE_URL}/api/user/listAllVehicles`);
const res = await fetch(`${BASE_URL}/api/user/listAllVehicles`,{
credentials:'include'
});
if (!res.ok) {
console.log("not success");
}
Expand Down

0 comments on commit 8afa7fd

Please sign in to comment.