Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6b52a31

Browse files
authored
fix(netlify): Disable autoSubfolderIndex for prerendered pages (nitrojs#3393)
1 parent 65b58f0 commit 6b52a31

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/presets/netlify/preset.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ const netlify = defineNitroPreset(
2222
dir: "{{ rootDir }}/.netlify/functions-internal",
2323
publicDir: "{{ rootDir }}/dist/{{ baseURL }}",
2424
},
25+
prerender: {
26+
// Prevents an unnecessary redirect from /page/ to /page when accessing prerendered content.
27+
// Reference: https://answers.netlify.com/t/support-guide-how-can-i-alter-trailing-slash-behaviour-in-my-urls-will-enabling-pretty-urls-help/31191
28+
// Reference: https://nitro.build/config#prerender
29+
autoSubfolderIndex: false,
30+
},
2531
rollupConfig: {
2632
output: {
2733
entryFileNames: "main.mjs",
@@ -69,6 +75,12 @@ const netlifyEdge = defineNitroPreset(
6975
serverDir: "{{ rootDir }}/.netlify/edge-functions/server",
7076
publicDir: "{{ rootDir }}/dist/{{ baseURL }}",
7177
},
78+
prerender: {
79+
// Prevents an unnecessary redirect from /page/ to /page when accessing prerendered content.
80+
// Reference: https://answers.netlify.com/t/support-guide-how-can-i-alter-trailing-slash-behaviour-in-my-urls-will-enabling-pretty-urls-help/31191
81+
// Reference: https://nitro.build/config#prerender
82+
autoSubfolderIndex: false,
83+
},
7284
rollupConfig: {
7385
output: {
7486
entryFileNames: "server.js",
@@ -119,6 +131,12 @@ const netlifyStatic = defineNitroPreset(
119131
dir: "{{ rootDir }}/dist",
120132
publicDir: "{{ rootDir }}/dist/{{ baseURL }}",
121133
},
134+
prerender: {
135+
// Prevents an unnecessary redirect from /page/ to /page when accessing prerendered content.
136+
// Reference: https://answers.netlify.com/t/support-guide-how-can-i-alter-trailing-slash-behaviour-in-my-urls-will-enabling-pretty-urls-help/31191
137+
// Reference: https://nitro.build/config#prerender
138+
autoSubfolderIndex: false,
139+
},
122140
commands: {
123141
preview: "npx serve ./",
124142
},

0 commit comments

Comments
 (0)