Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions packages/docusaurus/src/commands/serve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,21 @@ export async function serve(

// We do the redirect ourselves for a good reason
// server-handler is annoying and won't include /baseUrl/ in redirects
const normalizedUrl = applyTrailingSlash(req.url, {trailingSlash, baseUrl});
if (req.url !== normalizedUrl) {
redirect(res, normalizedUrl);
return;
// See https://github.com/facebook/docusaurus/issues/10078#issuecomment-2084932934
if (baseUrl !== '/') {
// Not super robust, but should be good enough for our use case
// See https://github.com/facebook/docusaurus/pull/10090
const looksLikeAsset = !!req.url.match(/.[a-z]{1,4}$/);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe *.mp3?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, not sure why I assumed extensions could only contain lowercase letters 😅

#10145

if (!looksLikeAsset) {
const normalizedUrl = applyTrailingSlash(req.url, {
trailingSlash,
baseUrl,
});
if (req.url !== normalizedUrl) {
redirect(res, normalizedUrl);
return;
}
}
}

// Remove baseUrl before calling serveHandler, because /baseUrl/ should
Expand Down