-
Notifications
You must be signed in to change notification settings - Fork 29.3k
Closed
Closed
Copy link
Labels
Image (next/image)Related to Next.js Image Optimization.Related to Next.js Image Optimization.
Description
Verify canary release
- I verified that the issue exists in Next.js canary release
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 21.4.0: Fri Mar 18 00:46:32 PDT 2022; root:xnu-8020.101.4~15/RELEASE_ARM64_T6000
Binaries:
Node: 16.14.2
npm: 7.24.2
Yarn: 1.22.17
pnpm: 6.27.1
Relevant packages:
next: 12.1.7-canary.1
react: 17.0.2
react-dom: 17.0.2
What browser are you using? (if relevant)
Microsoft Edge Version 101.0.1210.32 (Official build) (arm64)
How are you deploying your application? (if relevant)
next start
Describe the Bug
When we combine basePath
with trailingSlash
, the next/image
component does not applies the correct src
and srcSet
.
It always generates /_next/...
instead /<base-path>/_next/...
.
That leads to images not loading properly.
Expected Behavior
Add the basePath
into the generated src
and srcSets
so the image can be loaded properly.
To Reproduce
- clone this project: https://github.com/raulfdm/next-basepath-trailing-image-bug
- install the dependencies
npm install
- run the server
npm run dev
- open the app at
http://localhost:3001/docs/
- see the image component failing
- press the button that adds the base path
- the image should be properly displayed
If you run npm build && npm start
, the image will still be broken.
fbarrailla
Metadata
Metadata
Assignees
Labels
Image (next/image)Related to Next.js Image Optimization.Related to Next.js Image Optimization.