Skip to content

Commit

Permalink
Correctly set the JRT cookie samesSite parameter - fix #67
Browse files Browse the repository at this point in the history
  • Loading branch information
allgood committed Jun 18, 2024
1 parent ae309f7 commit 809fb74
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions backend/src/helpers/SendRefreshToken.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import { Response } from "express";
import { CookieOptions, Response } from "express";

export const SendRefreshToken = (res: Response, token: string): void => {
res.cookie("jrt", token, { httpOnly: true });
const cookieOptions: CookieOptions = { httpOnly: true };

if (process.env.BACKEND_URL.startsWith("https:") ) {
cookieOptions.sameSite = "none";
cookieOptions.secure = true;
}

res.cookie("jrt", token, cookieOptions);
};

0 comments on commit 809fb74

Please sign in to comment.