[PR #5272] [MERGED] feat: Improved API error page #31494

Closed
opened 2026-04-17 22:23:14 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/5272
Author: @ping-maxwell
Created: 10/13/2025
Status: Merged
Merged: 11/4/2025
Merged by: @Bekacru

Base: canaryHead: feat/improve-api-error-page


📝 Commits (10+)

  • 6938e03 feat: Improved API error page
  • 2ae1073 add: unknown pages
  • c5d944c chore: cleanup
  • e83c877 Merge branch 'canary' into feat/improve-api-error-page
  • 8038605 Merge branch 'canary' into feat/improve-api-error-page
  • 4d4e1ee add: customization options
  • 513aac2 Merge branch 'canary' into feat/improve-api-error-page
  • 8d1f19a chore: lint
  • 226a5dc Update docs/content/docs/errors/no_callback_url.mdx
  • 6a99763 Update docs/content/docs/errors/oauth_provider_not_found.mdx

📊 Changes

17 files changed (+908 additions, -105 deletions)

View changed files

📝 docs/app/docs/[[...slug]]/page.tsx (+15 -5)
📝 docs/components/floating-ai-search.tsx (+19 -19)
docs/content/docs/errors/account_already_linked_to_different_user.mdx (+64 -0)
docs/content/docs/errors/email_doesn't_match.mdx (+34 -0)
docs/content/docs/errors/email_not_found.mdx (+38 -0)
docs/content/docs/errors/index.mdx (+20 -0)
docs/content/docs/errors/invalid_callback_request.mdx (+47 -0)
docs/content/docs/errors/no_callback_url.mdx (+22 -0)
docs/content/docs/errors/no_code.mdx (+38 -0)
docs/content/docs/errors/oauth_provider_not_found.mdx (+47 -0)
docs/content/docs/errors/state_mismatch.mdx (+42 -0)
docs/content/docs/errors/state_not_found.mdx (+61 -0)
docs/content/docs/errors/unable_to_get_user_info.mdx (+31 -0)
docs/content/docs/errors/unable_to_link_account.mdx (+39 -0)
docs/content/docs/errors/unknown.mdx (+12 -0)
📝 packages/better-auth/src/api/routes/error.ts (+343 -81)
📝 packages/core/src/types/init-options.ts (+36 -0)

📄 Description

This PR introduces an improved API error page, as well as documentation for all of the common error codes seen on the api error page.

Added customizability to configure error page colors and other aspects.
Added support in the docs to check for a askai query param to auto-open the ask ai UI and prompt the bot based on the query param.
Added functionality in the error page to auto redirect to the auth config defiend error URL if it's defined, and to not show the BA error page if on production unless it's customized.

It uses light mode by default, unless it's able to detect system preference

https://github.com/user-attachments/assets/f0e9e55a-eb2e-4cc6-8d0f-53ccacaf42e2


Summary by cubic

Redesigned the API auth error page with clearer messaging, customization, and docs for common OAuth errors to speed up debugging.
The /api/auth/error endpoint now shows the error code and optional description, adds Ask AI and doc links, and redirects to a configured error URL or home in production when appropriate.

  • New Features
    • Modernized /api/auth/error UI with code badge, optional description, and Go home + Ask AI actions.
    • Links each error to detailed docs at /docs/errors/; unknown codes fall back to /docs/errors/unknown; docs support an askai query param to auto-open help.
    • Endpoint reads error and error_description query params and safely renders them.
    • Added auth config options to customize the default error page (colors, fonts, sizes, and decorations).
    • Redirects to onAPIError.errorURL if set; on production, auto-redirects to home unless the default page is customized.

Written for commit 9f3fc65714db5d79185ab8407e3bf31570229f21. Summary will update automatically 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/5272 **Author:** [@ping-maxwell](https://github.com/ping-maxwell) **Created:** 10/13/2025 **Status:** ✅ Merged **Merged:** 11/4/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `canary` ← **Head:** `feat/improve-api-error-page` --- ### 📝 Commits (10+) - [`6938e03`](https://github.com/better-auth/better-auth/commit/6938e030c6b19733091d72fbeeb8690feab6b3b1) feat: Improved API error page - [`2ae1073`](https://github.com/better-auth/better-auth/commit/2ae10730dbe4ea28e00df64dcb247e2c7843744a) add: unknown pages - [`c5d944c`](https://github.com/better-auth/better-auth/commit/c5d944cbd4fc5ac22a053987e7ab463aa9a332d5) chore: cleanup - [`e83c877`](https://github.com/better-auth/better-auth/commit/e83c8772539c8b260a2e1602e950960e90888c84) Merge branch 'canary' into feat/improve-api-error-page - [`8038605`](https://github.com/better-auth/better-auth/commit/8038605c8b769f44cf00a9cfd8d9960b52dfc4a0) Merge branch 'canary' into feat/improve-api-error-page - [`4d4e1ee`](https://github.com/better-auth/better-auth/commit/4d4e1ee9ba412a73d3fdd259e891872b2813b6f4) add: customization options - [`513aac2`](https://github.com/better-auth/better-auth/commit/513aac2c13d49333d59c046f216c55fdc2a0960b) Merge branch 'canary' into feat/improve-api-error-page - [`8d1f19a`](https://github.com/better-auth/better-auth/commit/8d1f19a14917a642bdb74e8ce2ae74b7d701bee5) chore: lint - [`226a5dc`](https://github.com/better-auth/better-auth/commit/226a5dcf57494c65508efa421a3240ef87f942b4) Update docs/content/docs/errors/no_callback_url.mdx - [`6a99763`](https://github.com/better-auth/better-auth/commit/6a997635daaf2d10fbb5cc7b37a8e341c7cb205f) Update docs/content/docs/errors/oauth_provider_not_found.mdx ### 📊 Changes **17 files changed** (+908 additions, -105 deletions) <details> <summary>View changed files</summary> 📝 `docs/app/docs/[[...slug]]/page.tsx` (+15 -5) 📝 `docs/components/floating-ai-search.tsx` (+19 -19) ➕ `docs/content/docs/errors/account_already_linked_to_different_user.mdx` (+64 -0) ➕ `docs/content/docs/errors/email_doesn't_match.mdx` (+34 -0) ➕ `docs/content/docs/errors/email_not_found.mdx` (+38 -0) ➕ `docs/content/docs/errors/index.mdx` (+20 -0) ➕ `docs/content/docs/errors/invalid_callback_request.mdx` (+47 -0) ➕ `docs/content/docs/errors/no_callback_url.mdx` (+22 -0) ➕ `docs/content/docs/errors/no_code.mdx` (+38 -0) ➕ `docs/content/docs/errors/oauth_provider_not_found.mdx` (+47 -0) ➕ `docs/content/docs/errors/state_mismatch.mdx` (+42 -0) ➕ `docs/content/docs/errors/state_not_found.mdx` (+61 -0) ➕ `docs/content/docs/errors/unable_to_get_user_info.mdx` (+31 -0) ➕ `docs/content/docs/errors/unable_to_link_account.mdx` (+39 -0) ➕ `docs/content/docs/errors/unknown.mdx` (+12 -0) 📝 `packages/better-auth/src/api/routes/error.ts` (+343 -81) 📝 `packages/core/src/types/init-options.ts` (+36 -0) </details> ### 📄 Description This PR introduces an improved API error page, as well as documentation for all of the common error codes seen on the api error page. Added customizability to configure error page colors and other aspects. Added support in the docs to check for a `askai` query param to auto-open the ask ai UI and prompt the bot based on the query param. Added functionality in the error page to auto redirect to the auth config defiend error URL if it's defined, and to not show the BA error page if on production unless it's customized. ## It uses light mode by default, unless it's able to detect system preference https://github.com/user-attachments/assets/f0e9e55a-eb2e-4cc6-8d0f-53ccacaf42e2 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Redesigned the API auth error page with clearer messaging, customization, and docs for common OAuth errors to speed up debugging. The /api/auth/error endpoint now shows the error code and optional description, adds Ask AI and doc links, and redirects to a configured error URL or home in production when appropriate. - **New Features** - Modernized /api/auth/error UI with code badge, optional description, and Go home + Ask AI actions. - Links each error to detailed docs at /docs/errors/<code>; unknown codes fall back to /docs/errors/unknown; docs support an askai query param to auto-open help. - Endpoint reads error and error_description query params and safely renders them. - Added auth config options to customize the default error page (colors, fonts, sizes, and decorations). - Redirects to onAPIError.errorURL if set; on production, auto-redirects to home unless the default page is customized. <sup>Written for commit 9f3fc65714db5d79185ab8407e3bf31570229f21. Summary will update automatically 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-04-17 22:23:15 -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#31494