Files
encoach_ui_odoo19/src/lib/session.ts
Talal Sharabi c01168976f Fix session cookie: use COOKIE_SECURE env var instead of NODE_ENV
The Secure flag was tied to NODE_ENV=production, which broke sessions
on HTTP staging servers. Using a dedicated COOKIE_SECURE env var
allows production-mode Next.js to run over HTTP for staging while
still enabling Secure cookies in production (HTTPS).

Made-with: Cursor
2026-03-16 11:48:28 +04:00

21 lines
616 B
TypeScript

// this file is a wrapper with defaults to be used in both API routes and `getServerSideProps` functions
import type {IronSessionOptions} from "iron-session";
import {User} from "@/interfaces/user";
export const sessionOptions: IronSessionOptions = {
password: process.env.SECRET_COOKIE_PASSWORD as string,
cookieName: "eCrop/ielts",
cookieOptions: {
secure: process.env.COOKIE_SECURE === "true",
},
};
// This is where we specify the typings of req.session.*
declare module "iron-session" {
interface IronSessionData {
user?: User | null;
token?: string;
envVariables?: {[key: string]: string};
}
}