We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 65e91a9 commit cb12233Copy full SHA for cb12233
2 files changed
app/middleware/trailing-slash.global.ts
@@ -0,0 +1,23 @@
1
+/**
2
+ * Removes trailing slashes from URLs.
3
+ *
4
+ * This middleware only runs in development to maintain consistent behavior.
5
+ * In production, Vercel handles this redirect via vercel.json.
6
7
+ * - /package/vue/ → /package/vue
8
+ * - /docs/getting-started/?query=value → /docs/getting-started?query=value
9
+ */
10
+export default defineNuxtRouteMiddleware(to => {
11
+ if (!import.meta.dev) return
12
+
13
+ if (to.path !== '/' && to.path.endsWith('/')) {
14
+ return navigateTo(
15
+ {
16
+ path: to.path.slice(0, -1),
17
+ query: to.query,
18
+ hash: to.hash,
19
+ },
20
+ { replace: true },
21
+ )
22
+ }
23
+})
vercel.json
@@ -1,5 +1,6 @@
{
"$schema": "https://openapi.vercel.sh/vercel.json",
+ "trailingSlash": false,
"redirects": [
"source": "/",
0 commit comments