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

Function redirect

apps/cloud/src/auth/ssr-gate.ts:187–205  ·  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

185 `${SESSION_COOKIE}=${sealed}; ${SESSION_COOKIE_ATTRIBUTES}; Max-Age=${SESSION_MAX_AGE}`;
186
187const redirect = (
188 location: string,
189 options?: {
190 /** Drop the (invalid) session + auth-hint cookies along the way. */
191 readonly clearSession?: boolean;
192 /** Persist a WorkOS-rotated sealed session (refresh tokens are single-use). */
193 readonly refreshedSession?: string | undefined;
194 },
195): Response => {
196 const headers = new Headers({ location });
197 if (options?.clearSession) {
198 headers.append("set-cookie", `${SESSION_COOKIE}=; ${SESSION_COOKIE_ATTRIBUTES}; Max-Age=0`);
199 headers.append("set-cookie", `${AUTH_HINT_COOKIE}=; Path=/; SameSite=Lax; Max-Age=0`);
200 }
201 if (options?.refreshedSession) {
202 headers.append("set-cookie", sessionSetCookie(options.refreshedSession));
203 }
204 return new Response(null, { status: 302, headers });
205};
206
207export const authGateMiddleware = createMiddleware({ type: "request" }).server(
208 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