MCPcopy Index your code
hub / github.com/triggerdotdev/trigger.dev / action

Function action

apps/webapp/app/routes/auth.github.ts:8–29  ·  view source on GitHub ↗
({ request })

Source from the content-addressed store, hash-verified

6export let loader: LoaderFunction = () => redirect("/login");
7
8export let action: ActionFunction = async ({ request }) => {
9 const url = new URL(request.url);
10 const redirectTo = url.searchParams.get("redirectTo");
11
12 try {
13 // call authenticate as usual, in successRedirect use returnTo or a fallback
14 return await authenticator.authenticate("github", request, {
15 successRedirect: redirectTo ?? "/",
16 failureRedirect: "/login",
17 });
18 } catch (error) {
19 // here we catch anything authenticator.authenticate throw, this will
20 // include redirects
21 // if the error is a Response and is a redirect
22 if (error instanceof Response) {
23 // we need to append a Set-Cookie header with a cookie storing the
24 // returnTo value
25 error.headers.append("Set-Cookie", await redirectCookie.serialize(redirectTo));
26 }
27 throw error;
28 }
29};
30
31export const redirectCookie = createCookie("redirect-to", {
32 maxAge: 60 * 60, // 1 hour

Callers

nothing calls this directly

Calls 2

serializeMethod · 0.65
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…