Next.js Discord

Discord Forum

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

Belgian Hare posted this in #help-forum
Open in Discord
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:

which is causing an unwanted redirect to:

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

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?