diff --git a/packages/docusaurus/src/server/index.ts b/packages/docusaurus/src/server/index.ts index 62a1ee2e041a..f140e88b6403 100644 --- a/packages/docusaurus/src/server/index.ts +++ b/packages/docusaurus/src/server/index.ts @@ -143,7 +143,7 @@ export async function load(siteDir: string): Promise { routesChunkNames, routesConfig, routesPaths, - } = await loadRoutes(pluginsRouteConfigs); + } = await loadRoutes(pluginsRouteConfigs, baseUrl); const genRegistry = generate( generatedFilesDir, diff --git a/packages/docusaurus/src/server/routes.ts b/packages/docusaurus/src/server/routes.ts index 512684a64ed5..ad9f8f27343a 100644 --- a/packages/docusaurus/src/server/routes.ts +++ b/packages/docusaurus/src/server/routes.ts @@ -5,7 +5,7 @@ * LICENSE file in the root directory of this source tree. */ -import {genChunkName} from '@docusaurus/utils'; +import {genChunkName, normalizeUrl} from '@docusaurus/utils'; import _ from 'lodash'; import {stringify} from 'querystring'; import { @@ -38,7 +38,10 @@ function getModulePath(target: Module): string { return `${target.path}${queryStr}`; } -export async function loadRoutes(pluginsRouteConfigs: RouteConfig[]) { +export async function loadRoutes( + pluginsRouteConfigs: RouteConfig[], + baseUrl: string, +) { const routesImports = [ `import React from 'react';`, `import ComponentCreator from '@docusaurus/ComponentCreator';`, @@ -46,7 +49,7 @@ export async function loadRoutes(pluginsRouteConfigs: RouteConfig[]) { const registry: { [chunkName: string]: ChunkRegistry; } = {}; - const routesPaths: string[] = ['404.html']; + const routesPaths: string[] = [normalizeUrl([baseUrl, '404.html'])]; const routesChunkNames: { [routePath: string]: ChunkNames; } = {};