INNER CODE UNIT · TypeScript

proxy

Jazee6/cloudflare-ai-web · proxy.ts:4

export async function proxy(request: NextRequest) {
  const password = process.env.APP_PASSWORD;
  if (!password) {
    return NextResponse.next();
  }

  // Allow the auth endpoint through
  if (request.nextUrl.pathname === "/api/auth") {
    return NextResponse.next();
  }

  const authorized = await isRequestAuthorized(request);
  if (!authorized) {
    return new Response("Unauthorized", { status: 401 });
  }

  return NextResponse.next();
}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…