Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/src/packages/backend/auth/cookie-names.ts
Views: 687
/*1We prefix the cookie with the base path so that it's possible to2have multiple distinct cocalc servers running on the same domain3without them colliding when doing development. However, this doesn't4help with multiple cocalc's on the same server with the same base5path serving on distinct ports. In that case, you can explicitly6set the remember me cookie name to whatever you want by7setting the following environment variable:89- COCALC_REMEMBER_ME_COOKIE_NAME -- env variable for arbitrary remember_me cookie name10- COCALC_API_COOKIE_NAME -- similar for the api cookie name.11*/1213import basePath from "@cocalc/backend/base-path";14import getLogger from "@cocalc/backend/logger";1516const log = getLogger("cookie-names");1718// Name of user provided remember_me cookie -- this is http-only and gets set19// when the user is signed in.20export const REMEMBER_ME_COOKIE_NAME =21process.env.COCALC_REMEMBER_ME_COOKIE_NAME ??22`${basePath.length <= 1 ? "" : encodeURIComponent(basePath)}remember_me`;2324log.debug("REMEMBER_ME_COOKIE_NAME", REMEMBER_ME_COOKIE_NAME);2526// Name of user provided api key cookie, with appropriate base path.27// This is set by the user when using the api from node.js, especially28// via a websocket.29export const API_COOKIE_NAME =30process.env.COCALC_API_COOKIE_NAME ??31`${basePath.length <= 1 ? "" : encodeURIComponent(basePath)}api_key`;3233log.debug("API_COOKIE_NAME", API_COOKIE_NAME);343536