fix: saml attributes for form post

This commit is contained in:
Stefan Benz
2025-03-12 10:04:51 +01:00
parent 3bed1c7b27
commit 44d5b0637a

View File

@@ -476,17 +476,17 @@ export async function GET(request: NextRequest) {
return NextResponse.redirect(url);
} else if (url && binding.case === "post") {
const formData = {
relayState: binding.value.relayState,
samlResponse: binding.value.samlResponse,
"RelayState": binding.value.relayState,
"SAMLResponse": binding.value.samlResponse,
};
// Convert form data to URL-encoded string
const formBody = new FormData();
const formBody = Object.entries(formData)
.map(
([key, value]) =>
encodeURIComponent(key) + "=" + encodeURIComponent(value),
)
.join("&");
formBody.append("RelayState", formData.relayState);
formBody.append("SAMLResponse", formData.samlResponse);
console.log(url)
console.log(formBody)
// Make a POST request to the external URL with the form data
const response = await fetch(url, {
method: "POST",
@@ -495,7 +495,6 @@ export async function GET(request: NextRequest) {
},
body: formBody,
});
console.log(response)
// Handle the response from the external URL
if (response.ok) {