Skip to content

Commit d4552db

Browse files
committed
trying cooky resolve
1 parent 0857f41 commit d4552db

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

src/controllers/authController.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ class AuthController {
3535
// Set JWT token as HTTP-only cookie
3636
res.cookie("token", result.token, {
3737
httpOnly: true,
38-
maxAge: 24 * 60 * 60 * 1000, // 1 day
39-
sameSite: "none",
4038
secure: true,
39+
sameSite: "none",
40+
maxAge: 24 * 60 * 60 * 1000, // 1 day
4141
});
4242

4343
return res.status(200).json({ message: "Login successful", ...result });

src/server.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ console.log(FRONTEND_URL);
1818
const corsOptions = {
1919
origin: FRONTEND_URL, // allow only your frontend
2020
credentials: true, // allow cookies to be sent
21+
methods: ["GET", "POST", "PUT", "DELETE", "OPTIONS"], // Explicitly allow methods
22+
allowedHeaders: ["Content-Type", "Authorization"], // Allow headers
2123
};
2224

2325
app.use(cors(corsOptions));

src/services/authServices.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export class AuthService {
99
email: string,
1010
password: string,
1111
name?: string,
12-
role?: "USER" | "ADMIN"
12+
role?: "USER" | "ADMIN",
1313
) {
1414
// 1️⃣ Check if user already exists
1515
const existingUser = await prisma.user.findUnique({ where: { email } });

0 commit comments

Comments
 (0)