Skip to content

Commit 8624093

Browse files
committed
Some changes
1 parent 55fd552 commit 8624093

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

src/app.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@ app.use(express.json());
1414
app.use(cookieParser());
1515
const dotenv = require("dotenv");
1616
dotenv.config();
17-
app.use(cors(
18-
{
19-
origin: "http://localhost:5173",
20-
credentials: true,
21-
}
22-
));
17+
app.use(cors({
18+
origin: [
19+
"http://localhost:5173",
20+
"https://dev-tinder-ax9m.onrender.com"
21+
],
22+
credentials: true,
23+
}));
2324

2425

2526
const authRouter = require("./routes/auth");

src/middlewares/auth.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const userAuth = async (req,res,next) => {
1111
try{
1212
const {token} = req.cookies;
1313
if(!token){
14-
return res.status(401).send("Unauthorized: Please Login First");
14+
return res.status(401).send("Unauthorized: token not provided");
1515
}
1616
// console.log("Token received:", token);
1717
// console.log("JWT_SECRET:", JWT_SECRET);

src/routes/auth.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ authRouter.post("/login", async (req,res) => {
4545
const isPasswordValid = await bcrypt.compare(password,hashedPassword);
4646
if(isPasswordValid){
4747
const token = await result.getJWT();
48-
res.cookie("token", token);
48+
res.cookie("token", token ,{
49+
httpOnly: true,
50+
secure: true,
51+
sameSite: "None",
52+
});
4953
res.send(result);
5054

5155
}else{

0 commit comments

Comments
 (0)