MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / redirect

Function redirect

apps/cloud/src/auth/ssr-gate.ts:167–185  ·  view source on GitHub ↗
(
  location: string,
  options?: {
    /** Drop the (invalid) session + auth-hint cookies along the way. */
    readonly clearSession?: boolean;
    /** Persist a WorkOS-rotated sealed session (refresh tokens are single-use). */
    readonly refreshedSession?: string | undefined;
  },
)

Source from the content-addressed store, hash-verified

165 `${SESSION_COOKIE}=${sealed}; ${SESSION_COOKIE_ATTRIBUTES}; Max-Age=${SESSION_MAX_AGE}`;
166
167const redirect = (
168 location: string,
169 options?: {
170 /** Drop the (invalid) session + auth-hint cookies along the way. */
171 readonly clearSession?: boolean;
172 /** Persist a WorkOS-rotated sealed session (refresh tokens are single-use). */
173 readonly refreshedSession?: string | undefined;
174 },
175): Response => {
176 const headers = new Headers({ location });
177 if (options?.clearSession) {
178 headers.append("set-cookie", `${SESSION_COOKIE}=; ${SESSION_COOKIE_ATTRIBUTES}; Max-Age=0`);
179 headers.append("set-cookie", `${AUTH_HINT_COOKIE}=; Path=/; SameSite=Lax; Max-Age=0`);
180 }
181 if (options?.refreshedSession) {
182 headers.append("set-cookie", sessionSetCookie(options.refreshedSession));
183 }
184 return new Response(null, { status: 302, headers });
185};
186
187export const authGateMiddleware = createMiddleware({ type: "request" }).server(
188 async ({ pathname, request, next }) => {

Callers 2

ssr-gate.tsFile · 0.70
secrets.tsxFile · 0.50

Calls 2

sessionSetCookieFunction · 0.85
appendMethod · 0.65

Tested by

no test coverage detected