fix: get env variable dynamically to avoid secret leakage
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import type { MiddlewareHandler } from "astro";
|
||||
import { options } from "./runtime.js";
|
||||
import { getOptions } from "./runtime.js";
|
||||
import { verifyAndDecode } from "./lib/sign.js";
|
||||
|
||||
function parseCookies(cookieHeader: string | null): Record<string, string> {
|
||||
@@ -31,6 +31,7 @@ function isProtected(pathname: string, patterns: string[]): boolean {
|
||||
|
||||
export const onRequest: MiddlewareHandler = async (context, next) => {
|
||||
const { request, locals, url } = context;
|
||||
const options = getOptions();
|
||||
const cookieName = options.cookie.name;
|
||||
const cookies = parseCookies(request.headers.get("cookie"));
|
||||
const token = cookies[cookieName];
|
||||
|
||||
Reference in New Issue
Block a user