-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(suspensive.org): resolve locale initialization issue #1311
Conversation
|
People can be co-author:
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Size Change: 0 B Total Size: 64.5 kB ℹ️ View Unchanged
|
CodSpeed Performance ReportMerging #1311 will create unknown performance changesComparing Summary
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1311 +/- ##
=======================================
Coverage 78.37% 78.37%
=======================================
Files 71 71
Lines 615 615
Branches 143 143
=======================================
Hits 482 482
Misses 127 127
Partials 6 6
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks...!❤️ So cool
import { type NextRequest, NextResponse } from 'next/server' | ||
|
||
const PUBLIC_FILE = /\.(.*)$/ | ||
|
||
export function middleware(req: NextRequest) { | ||
if ( | ||
req.nextUrl.pathname.startsWith('/_next') || | ||
req.nextUrl.pathname.includes('/api/') || | ||
PUBLIC_FILE.test(req.nextUrl.pathname) | ||
) { | ||
return | ||
} | ||
|
||
if ( | ||
!( | ||
req.nextUrl.pathname.startsWith('/en') || | ||
req.nextUrl.pathname.startsWith('/ko') | ||
) | ||
) { | ||
return NextResponse.redirect( | ||
new URL(`/en${req.nextUrl.pathname}${req.nextUrl.search}`, req.url) | ||
) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simple and auto detect locale..! not only redirecting English
Overview
I address an issue where undefined locale URLs defaulted to 'en' in Nextra documentation. I've implemented Nextra's middleware to recognize locale cookies.
2024-10-13.8.18.33.mov
[AS-IS]
[TO-BE]
icon.svg
)Issue
Nextra styles may appear broken in development. See Issue #3357. Could you please confirm if you're experiencing this as well?
PR Checklist