Github pages deploy Next.js assetPrefix not working

Viewed 1157

i am having problems deploying a gh-pages branch which is generated by next build && next export, my repo name is portfolio so the generated url is http://blackshot.github.io/portfolio/ i been reading that using assetPrefix and basePath works but not for me.

though this is my next.config.js

const isDev = process.env.NODE_ENV !== "production";
module.exports = {
    basePath: isDev ? "": "/portfolio",
    assetPrefix: isDev ? "": "/portfolio/"
}

browser is still 404ing assets 404ing

blackshot/portfolio is the repo if you want to take a look

1 Answers

As @Свободен said

When using next-image we should set the assetPrefix inside it.

const withImages = require('next-images')
const withPlugins = require('next-compose-plugins');
const isDev = process.env.NODE_ENV !== "production";

module.exports = withPlugins([
    [withImages, {
        assetPrefix: isDev ? "": "/repository_name/"
    }],
    {
        trailingSlash: true,
        basePath: isDev ? "": "/repository_name",
        assetPrefix: isDev ? "": "/repository_name/"    
    }
])
Related