Skip to content

feat: add static fallback error page for Kratos - #2698

Open
jaygiang wants to merge 2 commits into
masterfrom
feat/static-kratos-fallback-error-page
Open

feat: add static fallback error page for Kratos#2698
jaygiang wants to merge 2 commits into
masterfrom
feat/static-kratos-fallback-error-page

Conversation

@jaygiang

@jaygiang jaygiang commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

Related Issue or Design Document

Found a page that is bringing down our Core Web Vital Scores.

Using Vercel Speed Insights (real-user data), the Real Experience Score for our key pages:

ory.com/ → 99 (great)
docs/welcome→ 92 (great)
/docs/kratos/fallback/error] → 69 (poor — LCP 3.75s, TTFB 3.1s, FCP 3.7)

That one page has 68K real-user samples. It's one of the highest-traffic paths on the whole ory.com origin. Since the origin-level CrUX score pools every page's real-user samples, a high-traffic page with poor scores pulls the origin-level CWV number down.

The proof: our homepage's own scores are great (LCP 1.5s, TTFB 0.8s), but PageSpeed's "Origin" tab reads LCP 3.8s / TTFB 3.2s — nearly identical to the fallback page.

The error page serves the full Docusaurus app, so the payload kills our score.

Serves /docs/kratos/fallback/error as plain static HTML instead of a Docusaurus page.

  • Adds src/static/kratos/fallback/error.html
  • Deletes docs/kratos/fallback/error.mdx. Required, not cleanup: both build to the same path and the Docusaurus output silently wins.
  • Styling comes from src/css/theme.css and WelcomeFooter.tsx.

Checklist

  • [ x] I have read the contributing guidelines and signed the CLA.
  • I have referenced an issue containing the design document if my change introduces a new feature.
  • [ x] I have read the security policy.
  • [ x] I confirm that this pull request does not address a security vulnerability.
    If this pull request addresses a security vulnerability,
    I confirm that I got approval (please contact security@ory.com) from the maintainers to push the changes.
  • I have added tests that prove my fix is effective or that my feature works.
  • [ x] I have added the necessary documentation within the code base (if appropriate).

Further comments

Check out preview here - https://docs-git-feat-static-kratos-fallback-error-page-ory.vercel.app/docs/kratos/fallback/error

Screenshot 2026-07-29 at 3 48 10 PM

Summary by CodeRabbit

  • New Features
    • Added a fallback error page for cases where the error interface is not configured.
    • Includes setup guidance, configuration examples, responsive styling, and a user-friendly layout.

Copilot AI review requested due to automatic review settings July 29, 2026 22:44
@jaygiang
jaygiang requested a review from jonas-jonas July 29, 2026 22:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Ready to approve

The static asset routing aligns with the repo’s /docs/ baseUrl and Vercel cleanUrls: true, and no remaining references to the removed MDX route were found.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Pull request overview

This PR replaces the Docusaurus-rendered Kratos fallback error page with a plain static HTML file to reduce payload and improve Core Web Vitals for the high-traffic route /docs/kratos/fallback/error.

Changes:

  • Added a static HTML fallback page at src/static/kratos/fallback/error.html to be served with Vercel clean URLs.
  • Removed the Docusaurus doc page docs/kratos/fallback/error.mdx to avoid route/output conflicts.
File summaries
File Description
src/static/kratos/fallback/error.html Adds a standalone, light-only static HTML page (inline CSS) for the fallback error route.
docs/kratos/fallback/error.mdx Removes the Docusaurus MDX version so the static asset can take precedence for the same path.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Low

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a static Kratos fallback error page with responsive inline styling, configuration guidance for selfservice.flows.error.ui_url, an environment-variable reference, documentation link, and footer links.

Changes

Fallback error UI

Layer / File(s) Summary
Static fallback page
src/static/kratos/fallback/error.html
Adds the complete HTML document, light-themed responsive layout, configuration example, environment-variable guidance, documentation link, and footer links.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: aeneasr

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title is concise and accurately summarizes the main change: adding a static fallback error page for Kratos.
Description check ✅ Passed The description covers the motivation, change summary, checklist, and notes; the missing issue link is acceptable for a bug-fix style PR.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/static-kratos-fallback-error-page

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/static/kratos/fallback/error.html`:
- Around line 247-252: Update the copy-paste configuration example in the error
fallback snippet to use an HTTPS URL for selfservice.flows.error.ui_url,
changing the example endpoint from http://my-app.com/error to
https://my-app.com/error.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 0991219e-e8cd-4cfa-8696-322f898c997e

📥 Commits

Reviewing files that changed from the base of the PR and between 4a8e1bb and 39c0519.

⛔ Files ignored due to path filters (1)
  • docs/kratos/fallback/error.mdx is excluded by !**/*.mdx
📒 Files selected for processing (1)
  • src/static/kratos/fallback/error.html

Comment on lines +247 to +252
<div class="snippet">
<div class="snippet__title">path/to/kratos/config.yml</div>
<pre tabindex="0"><code><span class="key">selfservice</span>:
<span class="key">flows</span>:
<span class="key">error</span>:
<span class="key">ui_url</span>: http://my-app.com/error</code></pre>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win

Use HTTPS in the copy-paste configuration example.

http://my-app.com/error looks like a production endpoint and encourages sending the error identifier over plaintext. Change it to https://my-app.com/error, or make the example explicitly local with an http://localhost/... URL.

Proposed fix
-      <span class="key">ui_url</span>: http://my-app.com/error</code></pre>
+      <span class="key">ui_url</span>: https://my-app.com/error</code></pre>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<div class="snippet">
<div class="snippet__title">path/to/kratos/config.yml</div>
<pre tabindex="0"><code><span class="key">selfservice</span>:
<span class="key">flows</span>:
<span class="key">error</span>:
<span class="key">ui_url</span>: http://my-app.com/error</code></pre>
<div class="snippet">
<div class="snippet__title">path/to/kratos/config.yml</div>
<pre tabindex="0"><code><span class="key">selfservice</span>:
<span class="key">flows</span>:
<span class="key">error</span>:
<span class="key">ui_url</span>: https://my-app.com/error</code></pre>
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/static/kratos/fallback/error.html` around lines 247 - 252, Update the
copy-paste configuration example in the error fallback snippet to use an HTTPS
URL for selfservice.flows.error.ui_url, changing the example endpoint from
http://my-app.com/error to https://my-app.com/error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants