Next.js trailing slash exceptions
•vibekōdo•1 min read
Got bit by the trailing slash issue on Next.js.
If we enalbed trailingSlash
in next.config.js
, some urls will not have a trailing slash appended.
Quote from the doc:
- Static file URLs, such as files with extensions.
- Any paths under .well-known/.
I have a url like this:
xcode-16.3-and-react-native-7.6
If we enalbed trailingSlash
, it should become:
xcode-16.3-and-react-native-7.6/
But it does not. since it has a dot in the url, it is treated as a file. so no trailing slash is appended.
Reference:
https://nextjs.org/docs/app/api-reference/config/next-config-js/trailingSlash
https://github.com/vercel/next.js/issues/16617