File tree 1 file changed +15
-4
lines changed
packages/docusaurus/src/commands
1 file changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -76,10 +76,21 @@ export async function serve(
76
76
77
77
// We do the redirect ourselves for a good reason
78
78
// server-handler is annoying and won't include /baseUrl/ in redirects
79
- const normalizedUrl = applyTrailingSlash ( req . url , { trailingSlash, baseUrl} ) ;
80
- if ( req . url !== normalizedUrl ) {
81
- redirect ( res , normalizedUrl ) ;
82
- return ;
79
+ // See https://github.com/facebook/docusaurus/issues/10078#issuecomment-2084932934
80
+ if ( baseUrl !== '/' ) {
81
+ // Not super robust, but should be good enough for our use case
82
+ // See https://github.com/facebook/docusaurus/pull/10090
83
+ const looksLikeAsset = ! ! req . url . match ( / .[ a - z ] { 1 , 4 } $ / ) ;
84
+ if ( ! looksLikeAsset ) {
85
+ const normalizedUrl = applyTrailingSlash ( req . url , {
86
+ trailingSlash,
87
+ baseUrl,
88
+ } ) ;
89
+ if ( req . url !== normalizedUrl ) {
90
+ redirect ( res , normalizedUrl ) ;
91
+ return ;
92
+ }
93
+ }
83
94
}
84
95
85
96
// Remove baseUrl before calling serveHandler, because /baseUrl/ should
You can’t perform that action at this time.
0 commit comments