Skip to content

Commit

Permalink
try to fix / 308 redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
arvinxx committed Feb 7, 2025
1 parent 45ec01e commit 84fcd43
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ const defaultMiddleware = (request: NextRequest) => {
return NextResponse.next();

// refs: https://github.com/lobehub/lobe-chat/pull/5866
// 处理 URL 重写
// / /discover -> /discover/${route}
// new path: /${route}${originalPathname}
const nextPathname = `/${route}` + url.pathname;
// new handle segment rewrite: /${route}${originalPathname}
// / -> /zh-CN__0__dark
// /discover -> /zh-CN__0__dark/discover
const nextPathname = `/${route}` + (url.pathname === '/' ? '' : url.pathname);
console.log(`[rewrite] ${url.pathname} -> ${nextPathname}`);

url.pathname = nextPathname;
Expand Down

0 comments on commit 84fcd43

Please sign in to comment.