Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 0 additions & 4 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@
"dev": "nodemon src/index.ts",
"build": "tsc",
"start": "node dist/index.js",
{
"scripts": {
"test": "node --require ts-node/register --test tests/**/*.test.ts"
}
}
},
"keywords": [],
"author": "",
Expand Down
5 changes: 3 additions & 2 deletions backend/src/middleware/authGuard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ export async function authGuard(
res: Response,
next: NextFunction
): Promise<void> {
// Try to get token from cookie first, then from Authorization header
let token = req.cookies[ACCESS_TOKEN_COOKIE];
// Try to get token from cookie first (cookie-parser adds req.cookies;
// when unavailable, skip gracefully), then from Authorization header.
let token = req.cookies?.[ACCESS_TOKEN_COOKIE];
const header = req.headers.authorization;
if (!token && header?.startsWith("Bearer ")) {
token = header.slice(7);
Expand Down
Loading
Loading