Skip to content

Commit

Permalink
fix: do not try to access private runtime config on client (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe authored Jun 13, 2024
1 parent 56aa1d6 commit 70ab65f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/runtime/nitro/routes/__schema-org__/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import type { ModuleRuntimeConfig } from '../../../types'
import { useNitroOrigin, useRuntimeConfig } from '#imports'

export default defineEventHandler(async (e) => {
const runtimeConfig = (useRuntimeConfig()['nuxt-schema-org'] || useRuntimeConfig().public['nuxt-schema-org']) as any as ModuleRuntimeConfig
const _config = useRuntimeConfig()
const runtimeConfig = (import.meta.client ? _config.public['nuxt-schema-org'] : (_config['nuxt-schema-org'] || _config.public['nuxt-schema-org'])) as any as ModuleRuntimeConfig
const nitroOrigin = useNitroOrigin(e)
return {
nitroOrigin,
Expand Down
3 changes: 2 additions & 1 deletion src/runtime/nuxt/imports/useSchemaOrg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { useHead, useRuntimeConfig, useServerHead } from '#imports'

type Input = Parameters<typeof _useSchemaOrg>[0]
export function useSchemaOrg<T extends Input>(input: T): ActiveHeadEntry<UnheadAugmentation<T>> | void {
const config = (useRuntimeConfig()['nuxt-schema-org'] || useRuntimeConfig().public['nuxt-schema-org']) as ModuleRuntimeConfig
const _config = useRuntimeConfig()
const config = (import.meta.client ? _config.public['nuxt-schema-org'] : (_config['nuxt-schema-org'] || _config.public['nuxt-schema-org'])) as ModuleRuntimeConfig
const script = {
type: 'application/ld+json',
key: 'schema-org-graph',
Expand Down
3 changes: 2 additions & 1 deletion src/runtime/nuxt/plugin/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import {
export default defineNuxtPlugin({
name: 'nuxt-schema-org:defaults',
setup() {
const runtimeConfig = useRuntimeConfig()['nuxt-schema-org'] || useRuntimeConfig().public['nuxt-schema-org']
const _config = useRuntimeConfig()
const runtimeConfig = import.meta.client ? _config.public['nuxt-schema-org'] : (_config['nuxt-schema-org'] || _config.public['nuxt-schema-org'])
// get the head instance
const siteConfig = useSiteConfig()

Expand Down
3 changes: 2 additions & 1 deletion src/runtime/nuxt/plugin/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export default defineNuxtPlugin({
enforce: 'post',
setup(nuxtApp) {
const head = injectHead()
const config = (useRuntimeConfig()['nuxt-schema-org'] || useRuntimeConfig().public['nuxt-schema-org']) as ModuleRuntimeConfig
const _config = useRuntimeConfig()
const config = (import.meta.client ? _config.public['nuxt-schema-org'] : (_config['nuxt-schema-org'] || _config.public['nuxt-schema-org'])) as ModuleRuntimeConfig
const route = useRoute()

const siteConfig = useSiteConfig()
Expand Down

0 comments on commit 70ab65f

Please sign in to comment.