mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-09-13 22:56:05 -05:00
Zod validated config for security and ease of getting started
This commit is contained in:
@@ -1,21 +1,16 @@
|
||||
import { createCookieSessionStorage } from "react-router";
|
||||
import { ServerConfig } from "~/config.server";
|
||||
import { IS_E2E_TEST_RUN } from "~/utils/e2e";
|
||||
import invariant from "~/utils/invariant";
|
||||
import type { Theme } from "./provider";
|
||||
import { isTheme } from "./provider";
|
||||
|
||||
const TEN_YEARS_IN_SECONDS = 315_360_000;
|
||||
|
||||
if (process.env.NODE_ENV === "production") {
|
||||
invariant(process.env.SESSION_SECRET, "SESSION_SECRET is required");
|
||||
}
|
||||
const sessionSecret = process.env.SESSION_SECRET ?? "secret";
|
||||
|
||||
const themeStorage = createCookieSessionStorage({
|
||||
cookie: {
|
||||
name: "theme",
|
||||
secure: process.env.NODE_ENV === "production" && !IS_E2E_TEST_RUN,
|
||||
secrets: [sessionSecret],
|
||||
secure: ServerConfig.isProduction && !IS_E2E_TEST_RUN,
|
||||
secrets: [ServerConfig.sessionSecret],
|
||||
sameSite: "lax",
|
||||
path: "/",
|
||||
httpOnly: true,
|
||||
|
||||
Reference in New Issue
Block a user