Skip to content

fix: exclude static files from i18n middleware#779

Draft
CharlieMc0 wants to merge 1 commit intomainfrom
fix/openapi-swagger-middleware
Draft

fix: exclude static files from i18n middleware#779
CharlieMc0 wants to merge 1 commit intomainfrom
fix/openapi-swagger-middleware

Conversation

@CharlieMc0
Copy link
Member

@CharlieMc0 CharlieMc0 commented Mar 10, 2026

Summary

  • The Nextra locales middleware added in feat: i18n #764 intercepts all requests including static files in public/, causing the OpenAPI swagger page (/reference/network/openapi) and other static assets to 404
  • The middleware redirects static file requests into locale routing (x-matched-path: /en-US/404) instead of letting Next.js serve them from public/
  • Adds a matcher config to src/middleware.js to skip the middleware for static file paths (data/, img/, fonts/, favicon/, and common file extensions)

Test plan

🤖 Generated with Claude Code


Note

Low Risk
Low risk: adds a Next.js middleware matcher to avoid running locale routing on static asset and API paths; main risk is inadvertently excluding a path that should still be localized.

Overview
Adjusts the Nextra i18n middleware configuration by adding a config.matcher in src/middleware.js to skip locale middleware for static asset routes (e.g., data/, img/, fonts/, favicon, Next.js _next/*, api) and common file extensions.

This prevents requests for public/ assets (like Swagger/OpenAPI YAML) from being redirected into locale routing and returning 404s.

Written by Cursor Bugbot for commit 694cdbc. Configure here.

The Nextra locales middleware added in the i18n feature (#764) intercepts
all requests, including static files in public/. This causes the OpenAPI
swagger page and other static assets (images, fonts, data files) to 404
because the middleware redirects them into locale routing (/en-US/404).

Add a matcher config to skip the middleware for static file paths,
allowing Next.js to serve them directly from the public/ directory.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@vercel
Copy link

vercel bot commented Mar 10, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs-v2 Error Error Mar 10, 2026 4:39pm

Request Review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 10, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 33eafdfd-0fc5-4bb4-abac-95f72666ef0d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/openapi-swagger-middleware

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 and usage tips.

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.

1 participant