File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed
Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change 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+ } )
Original file line number Diff line number Diff line change 11{
22 "$schema" : " https://openapi.vercel.sh/vercel.json" ,
3+ "trailingSlash" : false ,
34 "redirects" : [
45 {
56 "source" : " /" ,
You can’t perform that action at this time.
0 commit comments