Answer the question
In order to leave comments, you need to log in
Why does Next.js give 404 when I refresh a page?
I built the project on Next.js into regular html, uploaded it to the hosting. It would seem that everything is fine, but when the page is reloaded, the hosting issues 404. Hosting on Apache. I created .htaccess and wrote this:
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.html [QSA,L]
Answer the question
In order to leave comments, you need to log in
I looked for an answer, setting next.config should help
https://nextjs.org/docs/api-reference/next.config....
module.exports = {
reactStrictMode: true,
trailingSlash: false,
exportPathMap: async function (
defaultPathMap,
{ dev, dir, outDir, distDir, buildId }
) {
return {
'/': { page: '/' },
'/about': { page: '/about' },
}
},
};
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question