Next.js Discord

Discord Forum

Trailing Slash option in my next.config is adding an extra trailing slash in /_next/image// path

Unanswered
Belgian Hare posted this in #help-forum
Open in Discord
Avatar
Belgian HareOP
In my next.config.js file I have the trailingSlash: true option set. This works as expected as all my site's paths include a trailing-slash and those without one are redirected to a path with a trailing slash.

There's unexpected behavior as it is also adding a trailing slash in my next/image URL path:
[site].com/_next/image//?url=image.jpg

which is causing an unwanted redirect to:
[site].com/_next/image/?url=image.jpg

For SEO purposes I can't set trailingSlash to false. Is there a way to get around this extra trailing slash?


I am on next v12 and using next/image.

1 Reply

Avatar
Belgian HareOP
The extra slash on /_next/image/ is removed if I turn off trailing slashes, but that's not an option for SEO purposes. anyone know of another workaround?