File tree Expand file tree Collapse file tree 13 files changed +120
-69
lines changed
Expand file tree Collapse file tree 13 files changed +120
-69
lines changed Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff 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 } ,
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff 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 {
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff 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 } ,
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff 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 } ,
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments