Reputation: 461
I have a pages/index.js
which is available at localhost:3000
when I run locally next
.
I want to run next build && next export
and deploy this page to Gitlab Pages. Due to how Gitlab Pages (or Github Pages for that matter) work, my page should be accessible to https://my-username.gitlab.io/my-nextjs-project/
. But because of this segment /my-nextjs-project/
that appears in the URL, I wasn't able to successfully deploy my app to Gitlab Pages.
If this would be a simple React app, I would set the output.publicPath
in webpack.config.js
. What's the analog of output.publicPath
in next.js? Or, do you know a public project deployed to Gitlab/Github Pages so I can check their configuration?
Thank you!
Upvotes: 5
Views: 4980
Reputation: 29
On your next.config.js add assetPrefix. Setting it up to assetPrefix: 'test' will put everything under test
module.exports = {
// some configuration
assetPrefix: isProduction ? '/{reponame}' : '',
// another configuration
}
Hope this helps, here is a link from Next.js on how to deploy it to GitHub pages. https://github.com/zeit/next.js/wiki/Deploying-a-Next.js-app-into-GitHub-Pages
Upvotes: 3