diff --git a/apps/login/src/app/(login)/saml-post/page.tsx b/apps/login/src/app/(login)/saml-post/page.tsx deleted file mode 100644 index d5765c8d56..0000000000 --- a/apps/login/src/app/(login)/saml-post/page.tsx +++ /dev/null @@ -1,43 +0,0 @@ -"use client"; - -import { useSearchParams } from "next/navigation"; -import { useEffect } from "react"; - -export default function SamlPost() { - const searchParams = useSearchParams(); - - const url = searchParams.get("url"); - const relayState = searchParams.get("RelayState"); - const samlResponse = searchParams.get("SAMLResponse"); - - useEffect(() => { - // Automatically submit the form after rendering - const form = document.getElementById("samlForm") as HTMLFormElement; - if (form) { - form.submit(); - } - }, []); - - if (!url || !relayState || !samlResponse) { - return ( -
Missing required parameters for SAML POST.
- ); - } - - return ( - - - - -Redirecting...
- - - ); -} diff --git a/apps/login/src/app/(login)/saml-post/route.ts b/apps/login/src/app/(login)/saml-post/route.ts new file mode 100644 index 0000000000..f2834f3884 --- /dev/null +++ b/apps/login/src/app/(login)/saml-post/route.ts @@ -0,0 +1,30 @@ +import { NextRequest, NextResponse } from "next/server"; + +export async function GET(request: NextRequest) { + const searchParams = request.nextUrl.searchParams; + const url = searchParams.get("url"); + const relayState = searchParams.get("RelayState"); + const samlResponse = searchParams.get("SAMLResponse"); + + if (!url || !relayState || !samlResponse) { + return new NextResponse("Missing required parameters", { status: 400 }); + } + + // Respond with an HTML form that auto-submits via POST + const html = ` + + + + + + `; + return new NextResponse(html, { + headers: { "Content-Type": "text/html" }, + }); +}