Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: do not try to access private runtime config on client #55

Merged
merged 1 commit into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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