N
Nuxtβ€’9mo ago
Markus Geilehner

Pre-Render not pre rendering

Hi πŸ™‹ I stumpled across a weird problem. My pre-rendered Routes are not working anymore. Havent found anything in the release notes - but the following code worked in previous versions / other projects. I am pre-rendering 2 routes on build, but the .html file generated are kind of empty:
<!DOCTYPE html><html><head><meta http-equiv="refresh" content="0; url=/_forms/call-back/"></head></html>
<!DOCTYPE html><html><head><meta http-equiv="refresh" content="0; url=/_forms/call-back/"></head></html>
I am using the 'nitro:config' hook to dynamically add routes to pre-render, which seems to work.
β„Ή Prerendering 2 routes nitro 8:21:51 AM
β”œβ”€ /_forms/schreib-uns-kontaktformular (73ms) nitro 8:21:51 AM
β”œβ”€ /_forms/call-back (75ms)
β„Ή Prerendering 2 routes nitro 8:21:51 AM
β”œβ”€ /_forms/schreib-uns-kontaktformular (73ms) nitro 8:21:51 AM
β”œβ”€ /_forms/call-back (75ms)
//nuxt.config.ts
import routePrerender from './routePrerender'
hooks: {
'nitro:config': routePrerender
}

//routePrerender.ts
//Here i am pushing route rules to the config:

config.routeRules = {
...config.routeRules,
[`/${story.full_slug}`]: {
prerender: true,
experimentalNoScripts: true,
},
}
//nuxt.config.ts
import routePrerender from './routePrerender'
hooks: {
'nitro:config': routePrerender
}

//routePrerender.ts
//Here i am pushing route rules to the config:

config.routeRules = {
...config.routeRules,
[`/${story.full_slug}`]: {
prerender: true,
experimentalNoScripts: true,
},
}
Any ideas why the routes are not pre-renderd? When running on DEV the routes work in SSR.
1 Reply
Joey
Joeyβ€’8mo ago
Doesn't the hook need to be a function? I am using it like this:
hooks: {
async 'nitro:config'(nitroConfig) {
const routesToGenerate = []
routesToGenerate.push('/some/route')
nitroConfig.prerender.routes.push(...routesToGenerate)
}
}
hooks: {
async 'nitro:config'(nitroConfig) {
const routesToGenerate = []
routesToGenerate.push('/some/route')
nitroConfig.prerender.routes.push(...routesToGenerate)
}
}
Want results from more Discord servers?
Add your server