[PR #6669] [MERGED] docs: add IdP-initiated SAML SSO workaround for Next.js #6813

Closed
opened 2026-03-13 13:12:40 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/6669
Author: @GautamBytes
Created: 12/10/2025
Status: Merged
Merged: 1/30/2026
Merged by: @himself65

Base: canaryHead: docs/saml-idp-workaround


📝 Commits (3)

  • ea4edf6 docs: add IdP-initiated SAML SSO workaround for Next.js
  • 43b93d6 docs: use req.url for robust redirect
  • 30cc9d5 docs(sso): refactor IdP-initiated SSO section to use tabs

📊 Changes

1 file changed (+24 additions, -0 deletions)

View changed files

📝 docs/content/docs/plugins/sso.mdx (+24 -0)

📄 Description

Description

This PR addresses the issue where IdP-initiated SAML SSO flows (e.g., clicking the app icon from an Okta dashboard) fail with a 404 error in Next.js App Router.

The Issue

As discussed in #6615, when the IdP POSTs to the callback URL, Better Auth redirects (302). The browser follows this with a GET request to the same URL. Since the default setup relies on a catch-all route that may not handle this specific GET context, the flow breaks.

The Fix

I have added a new documentation section "IdP-Initiated SSO (Next.js)" to docs/content/docs/plugins/sso.mdx. It provides the code snippet for creating an explicit route handler (route.ts) that manages both the POST (handshake) and the GET (redirect) methods.

Fixes #6615


Summary by cubic

Adds documentation for a Next.js workaround to support IdP-initiated SAML SSO and prevent 404s after the IdP redirect. Includes a route handler snippet that handles both POST (handshake) and GET (redirect) on the callback URL.

Written for commit 30cc9d558c. Summary will update on new commits.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/6669 **Author:** [@GautamBytes](https://github.com/GautamBytes) **Created:** 12/10/2025 **Status:** ✅ Merged **Merged:** 1/30/2026 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `docs/saml-idp-workaround` --- ### 📝 Commits (3) - [`ea4edf6`](https://github.com/better-auth/better-auth/commit/ea4edf657eeecef3f6523a4ceaa3a90676e6d5de) docs: add IdP-initiated SAML SSO workaround for Next.js - [`43b93d6`](https://github.com/better-auth/better-auth/commit/43b93d6dacf11bbdb5ef19b51fa49f6d56118512) docs: use req.url for robust redirect - [`30cc9d5`](https://github.com/better-auth/better-auth/commit/30cc9d558c2b3e96ff8c848962f747979b2d7623) docs(sso): refactor IdP-initiated SSO section to use tabs ### 📊 Changes **1 file changed** (+24 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/plugins/sso.mdx` (+24 -0) </details> ### 📄 Description ### Description This PR addresses the issue where IdP-initiated SAML SSO flows (e.g., clicking the app icon from an Okta dashboard) fail with a 404 error in Next.js App Router. ### The Issue As discussed in #6615, when the IdP POSTs to the callback URL, Better Auth redirects (302). The browser follows this with a `GET` request to the same URL. Since the default setup relies on a catch-all route that may not handle this specific `GET` context, the flow breaks. ### The Fix I have added a new documentation section **"IdP-Initiated SSO (Next.js)"** to `docs/content/docs/plugins/sso.mdx`. It provides the code snippet for creating an explicit route handler (`route.ts`) that manages both the `POST` (handshake) and the `GET` (redirect) methods. ### Related Issue Fixes #6615 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Adds documentation for a Next.js workaround to support IdP-initiated SAML SSO and prevent 404s after the IdP redirect. Includes a route handler snippet that handles both POST (handshake) and GET (redirect) on the callback URL. <sup>Written for commit 30cc9d558c2b3e96ff8c848962f747979b2d7623. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-03-13 13:12:40 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#6813