mirror of
https://github.com/zuiidea/antd-admin
synced 2026-10-30 13:23:49 +00:00
fix(docs): intercept mockServiceWorker.js before Nextra catch-all
Made-with: Cursor
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import type { NextRequest } from "next/server";
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
/**
|
||||
* Browsers or other localhost apps (e.g. MSW) may request `/mockServiceWorker.js`.
|
||||
* Without this, the request hits `[[...mdxPath]]` and Nextra tries to load it as MDX.
|
||||
*/
|
||||
export function middleware(request: NextRequest) {
|
||||
if (request.nextUrl.pathname === "/mockServiceWorker.js") {
|
||||
return new NextResponse(
|
||||
"// antd-admin docs: no MSW; unregister stray workers from other localhost apps if needed.\n",
|
||||
{
|
||||
status: 200,
|
||||
headers: {
|
||||
"content-type": "application/javascript; charset=utf-8",
|
||||
"cache-control": "no-store",
|
||||
},
|
||||
},
|
||||
);
|
||||
}
|
||||
return NextResponse.next();
|
||||
}
|
||||
|
||||
export const config = {
|
||||
matcher: "/mockServiceWorker.js",
|
||||
};
|
||||
Reference in New Issue
Block a user