diff --git a/backend/package.json b/backend/package.json index 2aefa21..8253dd0 100644 --- a/backend/package.json +++ b/backend/package.json @@ -5,7 +5,8 @@ "type": "module", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "dev": "node --watch ./src/index.js" + "dev": "node --watch ./src/index.js", + "start": "node ./src/index.js" }, "keywords": [], "author": "", diff --git a/backend/src/controllers/user.controller.js b/backend/src/controllers/user.controller.js index 1993476..c9dafb0 100644 --- a/backend/src/controllers/user.controller.js +++ b/backend/src/controllers/user.controller.js @@ -30,8 +30,10 @@ export async function signinController(req, res) { const { email, password } = req.body; const { token, userData } = await signinService(email, password); res.cookie("livepoll-access-token", token, { - httpOnly: true, - maxAge: 10 * 24 * 60 * 60 * 1000, // 10 days + httpOnly: true, + secure: true, + sameSite: "None", + path: "/" }).status(200).json({ success : true, message : "User signedin successfully.", diff --git a/backend/src/index.js b/backend/src/index.js index 4320ea2..8027404 100644 --- a/backend/src/index.js +++ b/backend/src/index.js @@ -20,18 +20,22 @@ app.use('/docs', swaggerUi.serve, swaggerUi.setup(swaggerDocs)); const io = new Server(httpServer, { cors: { origin: CLIENT_URL, - methods: ["GET", "POST", "PUT", "DELETE"] + methods: ["GET", "POST", "PUT", "DELETE"], + credentials: true } }) + handlePollSocket(io); app.use(cookieParser()); -app.use(cors({ - origin: CLIENT_URL, - credentials: true -})) +app.use(cors( + { + origin: CLIENT_URL, + credentials: true, + } +)) app.use(express.json()) app.get("/ping", (_req, res) => { res.json({ message: "pong" })