harlan-zw / nuxt-site-config

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

Using `useSiteConfig` inside a server route fail #2

Closed Barbapapazes closed 1 year ago

Barbapapazes commented 1 year 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 1 year 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 1 year ago

Will check, thx

Barbapapazes commented 1 year 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!