404 页面。我该如何解决这个问题? 重现步骤
gatsby develop
单击链接从索引页面导航到关于页面。
索引页:src/pages/index.js
import React from 'react';
import { Link } from 'gatsby';
const IndexPage = () => {
return (
<main>
<h1>Index Page</h1>
<Link to="/about">About Me</Link>
</main>
);
};
export default IndexPage;
src/pages/about.js
import React from 'react';
import { Link } from 'gatsby';
const AboutPage = () => {
return (
<main>
<h1>About Page</h1>
<Link to="/">Back To Home</Link>
</main>
);
};
export default AboutPage;
{
"name": "my-gatsby-site",
"version": "1.0.0",
"private": true,
"description": "My Gatsby Site",
"keywords": [
"gatsby"
],
"scripts": {
"develop": "gatsby develop",
"start": "gatsby develop",
"build": "gatsby build",
"serve": "gatsby serve",
"clean": "gatsby clean"
},
"dependencies": {
"gatsby": "^3.6.2",
"gatsby-plugin-gatsby-cloud": "^2.8.1",
"react": "^17.0.1",
"react-dom": "^17.0.1"
}
}
// gatsby-browser.js
exports.onInitialClientRender = () => {
// dirty fix for missing popstate listener
const GATSBY_NAVIGATE = window.___navigate || {}
window.addEventListener('popstate', () =>
GATSBY_NAVIGATE(window.location.pathname, { replace: true })
)
}
https://github.com/gatsbyjs/gatsby/issues/7261#issuecomment-414304749