harlan-zw / nuxt-site-config

Unifying site config with powerful and flexible APIs, for module authors and users.
https://nuxtseo.com/site-config
61 stars 3 forks source link

Using `useSiteConfig` inside a server route fail #2

Closed Barbapapazes closed 10 months ago

Barbapapazes commented 10 months ago

Describe the bug

Hello,

I'm trying to use the composable useSiteConfig inside a server route and I got this error.

image

Reproduction

No response

System / Nuxt Info

------------------------------
- Operating System: Linux
- Node Version:     v18.16.1
- Nuxt Version:     3.6.5
- Nitro Version:    2.5.2
- Package Manager:  pnpm@8.6.12
- Builder:          vite
- User Config:      app, modules, css, nitro, content, unocss, site, sitemap, devtools
- Runtime Modules:  @nuxt/content@2.7.2, @vueuse/nuxt@10.3.0, @unocss/nuxt@0.54.3, nuxt-simple-robots@3.1.0, nuxt-simple-sitemap@3.1.5, @nuxthq/studio@0.13.4
- Build Modules:    -
------------------------------
harlan-zw commented 10 months ago

Can you provide the code you're using and in what context exactly?

In Nuxt server code the usage should be the same, but in Nitro code you need to pass the H3Event in as the first argument.

const siteConfig = useSiteConfig(event)
Barbapapazes commented 10 months ago

Will check, thx

Barbapapazes commented 10 months ago

Can you provide the code you're using and in what context exactly?

In Nuxt server code the usage should be the same, but in Nitro code you need to pass the H3Event in as the first argument.

const siteConfig = useSiteConfig(event)

Ho nice, it works so well!