Markus Geilehner
Markus Geilehner
NNuxt
Created by Markus Geilehner on 4/9/2024 in #❓・help
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.
2 replies
NNuxt
Created by Markus Geilehner on 5/14/2023 in #❓・help
Composable used in Component is not reactive
I created a composable "useTimeRecordings()" where I manage state of a few fields e.g.:
function useTimeRecordings() { ...
const recordingsPage = useState<number>('recordings-page', () => 1)
const recordings = useState<TimeRecord[] | null>('recordings', () => null)

if (recordings.value === null) {
fetchRecordings(true).then(() => {
console.log('fetch', recordings.value) //recordings set correctly...
})
}

return {
recordings: computed(() => recordings.value)
}
}
function useTimeRecordings() { ...
const recordingsPage = useState<number>('recordings-page', () => 1)
const recordings = useState<TimeRecord[] | null>('recordings', () => null)

if (recordings.value === null) {
fetchRecordings(true).then(() => {
console.log('fetch', recordings.value) //recordings set correctly...
})
}

return {
recordings: computed(() => recordings.value)
}
}
And in my component I am using:
const {recordings} = useTimeRecordings()
const {recordings} = useTimeRecordings()
And this value is not updated. Any idea why? I am assigning the array correctly, I am using computed props as return and yeah. 🤔 Is it because i am not "awaiting" the records? 🤔
5 replies
NNuxt
Created by Markus Geilehner on 3/13/2023 in #❓・help
Mysql Database
How would one connect to a e.g external MySql Database? Would it work by just installing the mysql node package or ist there a more convenient way to handle this, since theres no Mysql unstorage driver? Talking about Nuxt 3 Server side (server/api) to handle logic/queries.
4 replies