Spaces:
Running
Running
File size: 564 Bytes
5da61b4 067b52a 41b9769 067b52a 3ddb8c6 41b9769 5da61b4 3ddb8c6 5da61b4 3ddb8c6 067b52a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
import { COOKIE_NAME } from "$env/static/private";
import type { Handle } from "@sveltejs/kit";
import { addYears } from "date-fns";
export const handle: Handle = async ({ event, resolve }) => {
const token = event.cookies.get(COOKIE_NAME);
event.locals.sessionId = token || crypto.randomUUID();
// Refresh cookie expiration date
event.cookies.set(COOKIE_NAME, event.locals.sessionId, {
path: "/",
sameSite: "lax",
secure: true,
httpOnly: true,
expires: addYears(new Date(), 1),
});
const response = await resolve(event);
return response;
};
|