Skip to content

Commit c1ed433

Browse files
committed
fix
1 parent 24d6824 commit c1ed433

File tree

13 files changed

+120
-69
lines changed

13 files changed

+120
-69
lines changed

.github/workflows/agent-docs.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ jobs:
4141
run: yarn build:docs
4242
env:
4343
NEXT_PUBLIC_BASE_URL: "http://localhost:3000"
44-
NEXT_PUBLIC_DOCS_URL: "https://docs.medusajs.com"
45-
NEXT_PUBLIC_RESOURCES_URL: "https://docs.medusajs.com"
46-
NEXT_PUBLIC_USER_GUIDE_URL: "https://docs.medusajs.com"
44+
NEXT_PUBLIC_DOCS_URL: "http://localhost:3000"
45+
NEXT_PUBLIC_RESOURCES_URL: "http://localhost:3000"
46+
NEXT_PUBLIC_USER_GUIDE_URL: "http://localhost:3000"
4747
NEXT_PUBLIC_ENV: CI
4848
NODE_ENV: production
4949

www/apps/bloom/middleware.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { NextRequest, NextResponse } from "next/server"
2+
3+
export function middleware(req: NextRequest) {
4+
const accept = req.headers.get("accept") ?? ""
5+
6+
if (accept.includes("text/markdown") || accept.includes("text/plain")) {
7+
const { pathname } = req.nextUrl
8+
const url = req.nextUrl.clone()
9+
url.pathname = `/md-content${pathname === "/" ? "" : pathname}`
10+
return NextResponse.rewrite(url)
11+
}
12+
}
13+
14+
export const config = {
15+
matcher: "/((?!_next/static|_next/image|favicon.ico|md-content).*)",
16+
}

www/apps/bloom/next.config.mjs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -152,17 +152,6 @@ const nextConfig = {
152152
source: "/:path*.md",
153153
destination: "/md-content/:path*",
154154
},
155-
{
156-
source: "/:path*",
157-
has: [
158-
{
159-
type: "header",
160-
key: "Accept",
161-
value: ".*(text/markdown|text/plain).*",
162-
},
163-
],
164-
destination: "/md-content/:path*",
165-
},
166155
],
167156
}
168157
},

www/apps/book/middleware.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { NextRequest, NextResponse } from "next/server"
2+
3+
const EXCLUDED_PREFIXES = [
4+
"/resources",
5+
"/api",
6+
"/ui",
7+
"/user-guide",
8+
"/cloud",
9+
"/md-content",
10+
"/_next",
11+
"/favicon",
12+
]
13+
14+
export function middleware(req: NextRequest) {
15+
const accept = req.headers.get("accept") ?? ""
16+
17+
if (
18+
accept.includes("text/markdown") ||
19+
accept.includes("text/plain")
20+
) {
21+
const { pathname } = req.nextUrl
22+
const isExcluded = EXCLUDED_PREFIXES.some((prefix) =>
23+
pathname.startsWith(prefix)
24+
)
25+
26+
if (!isExcluded) {
27+
const url = req.nextUrl.clone()
28+
url.pathname = `/md-content${pathname === "/" ? "" : pathname}`
29+
return NextResponse.rewrite(url)
30+
}
31+
}
32+
}
33+
34+
export const config = {
35+
matcher: "/((?!_next/static|_next/image|favicon.ico).*)",
36+
}

www/apps/book/next.config.mjs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -137,17 +137,7 @@ const nextConfig = {
137137
source: "/:path((?!resources|api|ui|user-guide|cloud).*).md",
138138
destination: "/md-content/:path*",
139139
},
140-
{
141-
source: "/:path((?!resources|api|ui|user-guide|cloud).*)*",
142-
has: [
143-
{
144-
type: "header",
145-
key: "Accept",
146-
value: ".*(text/markdown|text/plain).*",
147-
},
148-
],
149-
destination: "/md-content/:path*",
150-
},
140+
151141
],
152142
fallback: [
153143
{

www/apps/cloud/middleware.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { NextRequest, NextResponse } from "next/server"
2+
3+
export function middleware(req: NextRequest) {
4+
const accept = req.headers.get("accept") ?? ""
5+
6+
if (accept.includes("text/markdown") || accept.includes("text/plain")) {
7+
const { pathname } = req.nextUrl
8+
const url = req.nextUrl.clone()
9+
url.pathname = `/md-content${pathname === "/" ? "" : pathname}`
10+
return NextResponse.rewrite(url)
11+
}
12+
}
13+
14+
export const config = {
15+
matcher: "/((?!_next/static|_next/image|favicon.ico|md-content).*)",
16+
}

www/apps/cloud/next.config.mjs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -175,17 +175,6 @@ const nextConfig = {
175175
source: "/:path*.md",
176176
destination: "/md-content/:path*",
177177
},
178-
{
179-
source: "/:path*",
180-
has: [
181-
{
182-
type: "header",
183-
key: "Accept",
184-
value: ".*(text/markdown|text/plain).*",
185-
},
186-
],
187-
destination: "/md-content/:path*",
188-
},
189178
],
190179
}
191180
},

www/apps/resources/middleware.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { NextRequest, NextResponse } from "next/server"
2+
3+
export function middleware(req: NextRequest) {
4+
const accept = req.headers.get("accept") ?? ""
5+
6+
if (accept.includes("text/markdown") || accept.includes("text/plain")) {
7+
const { pathname } = req.nextUrl
8+
const url = req.nextUrl.clone()
9+
url.pathname = `/md-content${pathname === "/" ? "" : pathname}`
10+
return NextResponse.rewrite(url)
11+
}
12+
}
13+
14+
export const config = {
15+
matcher: "/((?!_next/static|_next/image|favicon.ico|md-content).*)",
16+
}

www/apps/resources/next.config.mjs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -306,17 +306,6 @@ const nextConfig = {
306306
source: "/:path*.md",
307307
destination: "/md-content/:path*",
308308
},
309-
{
310-
source: "/:path*",
311-
has: [
312-
{
313-
type: "header",
314-
key: "Accept",
315-
value: ".*(text/markdown|text/plain).*",
316-
},
317-
],
318-
destination: "/md-content/:path*",
319-
},
320309
],
321310
}
322311
},

www/apps/ui/middleware.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { NextRequest, NextResponse } from "next/server"
2+
3+
export function middleware(req: NextRequest) {
4+
const accept = req.headers.get("accept") ?? ""
5+
6+
if (accept.includes("text/markdown") || accept.includes("text/plain")) {
7+
const { pathname } = req.nextUrl
8+
const url = req.nextUrl.clone()
9+
url.pathname = `/md-content${pathname === "/" ? "" : pathname}`
10+
return NextResponse.rewrite(url)
11+
}
12+
}
13+
14+
export const config = {
15+
matcher: "/((?!_next/static|_next/image|favicon.ico|md-content).*)",
16+
}

0 commit comments

Comments
 (0)