mirror of
https://github.com/webstudio-is/webstudio.git
synced 2026-12-02 13:25:40 +09:00
## Description - Use secure cookie at local development - Fix layout nesting https://remix.run/docs/en/main/file-conventions/routes#nested-urls-without-layout-nesting ## Steps for reproduction 1. click button 2. expect xyz ## Code Review - [ ] hi @kof, I need you to do - conceptual review (architecture, feature-correctness) - detailed review (read every line) - test it on preview ## Before requesting a review - [ ] made a self-review - [ ] added inline comments where things may be not obvious (the "why", not "what") ## Before merging - [ ] tested locally and on preview environment (preview dev login: 5de6) - [ ] updated [test cases](https://github.com/webstudio-is/webstudio/blob/main/apps/builder/docs/test-cases.md) document - [ ] added tests - [ ] if any new env variables are added, added them to `.env` file
19 lines
774 B
TypeScript
19 lines
774 B
TypeScript
import { createCookieSessionStorage } from "@remix-run/node";
|
|
import env from "~/env/env.server";
|
|
|
|
// export the whole sessionStorage object
|
|
export const sessionStorage = createCookieSessionStorage({
|
|
cookie: {
|
|
maxAge: 60 * 60 * 24 * 30,
|
|
name: "_session", // use any name you want here
|
|
sameSite: "lax", // this helps with CSRF
|
|
path: "/", // remember to add this so the cookie will work in all routes
|
|
httpOnly: true, // for security reasons, make this cookie http only
|
|
secrets: env.AUTH_SECRET ? [env.AUTH_SECRET] : undefined, // replace this with an actual secret
|
|
secure: env.SECURE_COOKIE,
|
|
},
|
|
});
|
|
|
|
// you can also export the methods individually for your own usage
|
|
export const { getSession, commitSession, destroySession } = sessionStorage;
|