Недавно я впервые развернул наш сайт Docusaurus и столкнулся со странной проблемой с маршрутизацией.
Каждая страница в папке /docs на короткое время отображает страницу 404.html при непосредственном переходе на страницу. Однако, если я нажму на боковой панели, страницы отобразятся правильно.
Это происходит только в папке /docs. Если я нажму на ссылку на главной странице, я не увижу 404.
Я не могу воспроизвести эту проблему локально. Я пробовал и yarn start
, и yarn build/serve
, и в обоих случаях приложение работает нормально. Я не вижу никаких ошибок 404, ошибок консоли и т. д. Полезная нагрузка ответа 404 — это страница OOTB Docusaurus, я не делал никаких настроек для нее или того, как она обрабатывается.
Прикреплен GIF-файл, показывающий поведение, и снимок экрана, показывающий, что браузер видит жесткую ошибку 404 в моей среде, отличной от локальной.
И вот мой файл конфигурации:
// @ts-check
// Note: type annotations allow type checking and IDEs autocompletion
const lightCodeTheme = require('prism-react-renderer/themes/github');
const darkCodeTheme = require('prism-react-renderer/themes/dracula');
/** @type {import('@docusaurus/types').Config} */
const config = {
title: 'Guidebook',
tagline: 'Engineering Information',
url: 'https://guidebook.our-internal-domain.tools/',
baseUrl: '/',
onBrokenLinks: 'throw',
onBrokenMarkdownLinks: 'throw',
favicon: 'img/favicon.png',
organizationName: 'Guidebook',
projectName: 'Guidebook',
presets: [
[
'classic',
/** @type {import('@docusaurus/preset-classic').Options} */
({
docs: {
sidebarPath: require.resolve('./sidebars.js'),
editUrl: 'https://git.our-internal-domain.com/tech-standards/tech-guidebook'
},
blog: false,
theme: {
customCss: require.resolve('./src/css/custom.css')
}
// debug: true
})
]
],
themeConfig: {
navbar: {
title: 'Home',
logo: {
alt: 'Home',
src: 'img/TechnologyGuidebook-Icon_Red_Small.svg'
},
items: [
{
type: 'doc',
docId: 'intro',
position: 'left',
label: 'Guidebook'
},
{
href: 'https://git.our-internal-domain.com/tech-standards/tech-guidebook',
label: 'GitHub',
position: 'right'
}
]
},
footer: {
style: 'dark',
links: [
{
title: 'Community',
items: [
{
label: 'Stack Overflow',
href: 'https://stackoverflow.com/questions/tagged/docusaurus'
}
]
},
{
title: 'More',
items: [
{
label: 'GitHub',
href: 'https://github.com/facebook/docusaurus'
}
]
}
],
copyright: `Copyright © ${new Date().getFullYear()} Guidebook V2, Inc. Built with Docusaurus.`
},
prism: {
theme: lightCodeTheme,
darkTheme: darkCodeTheme
}
}
};
module.exports = config;