MCPcopy Create free account
hub / github.com/aws-samples/remote-swe-agents / proxy

Function proxy

packages/webapp/src/proxy.ts:9–30  ·  view source on GitHub ↗
(request: NextRequest)

Source from the content-addressed store, hash-verified

7// DO NOT remove any existing logic if you are not sure!
8
9export async function proxy(request: NextRequest) {
10 const response = NextResponse.next();
11
12 const authenticated = await runWithAmplifyServerContext({
13 nextServerContext: { request, response },
14 operation: async (contextSpec) => {
15 try {
16 const session = await fetchAuthSession(contextSpec);
17 return session.tokens?.accessToken !== undefined && session.tokens?.idToken !== undefined;
18 } catch (error) {
19 console.log(error);
20 return false;
21 }
22 },
23 });
24
25 if (authenticated) {
26 return response;
27 }
28
29 return NextResponse.redirect(new URL('/sign-in', request.url));
30}
31
32export const config = {
33 matcher: [

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected