Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
464 views
in Technique[技术] by (71.8m points)

reactjs - How does Next.js basePath works for images?

I'm trying to add a basePath to my next.config.js, it works well for the website content. But all the images are broken.

// next.config.js
module.exports = {
  basePath: '/my-sub-url',
  assetPrefix: '/my-sub-url/'
}

I also tried adding all the image path to something like this:

src="/my-sub-url/image.jpg"

And I also tried created a my-sub-url folder in my public folder, but still no luck.

My codes and images are all in my GitHub private project, and I'm deploying using Vercel.com. Currently I'm in Next.js v10 canary.

Is this because I host my images in GitHub? Or any other settings that I've missed out on? Don't seem to be find anything in Vercel/Next.js docs and other online places.

question from:https://stackoverflow.com/questions/65930789/how-does-next-js-basepath-works-for-images

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...