refactor: migrate pages and API routes to App Router
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
|
||||
export async function GET(
|
||||
req: NextRequest,
|
||||
{ params }: { params: Promise<{ provider: string }> },
|
||||
) {
|
||||
const { provider } = await params;
|
||||
const challenges = req.nextUrl.searchParams.getAll("challenge");
|
||||
const challenge = challenges[0];
|
||||
if (
|
||||
!["google", "slack"].includes(provider) ||
|
||||
challenges.length !== 1 ||
|
||||
!/^[-_a-zA-Z0-9]{43}$/.test(challenge)
|
||||
)
|
||||
return NextResponse.json({ error: "invalid_request" }, { status: 400 });
|
||||
const origin = process.env.FOUNDRY_API_ORIGIN || "https://api.foundry.entroia.com";
|
||||
const project = process.env.NEXT_PUBLIC_FOUNDRY_PROJECT || "endoleap";
|
||||
return NextResponse.redirect(
|
||||
origin + "/projects/" + encodeURIComponent(project) + "/auth/" + provider + "?challenge=" + challenge,
|
||||
{ status: 302, headers: { "Cache-Control": "no-store" } },
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user