Skip to content

Commit

Permalink
fix: include both public + private runtime config
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed May 17, 2022
1 parent db9867f commit 3a478ef
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export default defineNuxtModule<SanityModuleOptions>({
}

// Final resolved configuration
const { projectId, dataset } = nuxt.options.publicRuntimeConfig.sanity = defu(nuxt.options.publicRuntimeConfig.sanity, {
const { projectId, dataset } = nuxt.options.runtimeConfig.public.sanity = defu(nuxt.options.runtimeConfig.public.sanity, {
useCdn: options.useCdn,
projectId: options.projectId,
dataset: options.dataset,
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/composables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const useSanity = (client = 'default'): SanityHelper => {
nuxtApp._sanity = nuxtApp._sanity || {}

const $config = useRuntimeConfig()
const { additionalClients = {}, ...options } = $config.sanity
const { additionalClients = {}, ...options } = defu($config.sanity, $config.public.sanity)

if (!options.disableSmartCdn && nuxtApp.$preview) {
options.useCdn = false
Expand Down
7 changes: 6 additions & 1 deletion test/stubs/imports.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ export { createClient as createSanityClient } from '../../src/runtime/client'
export const useNuxtApp = () => ({})
export const useRuntimeConfig = () => ({
sanity: {
projectId: 'test-project',
token: 'test',
},
public: {
sanity: {
projectId: 'test-project',
},
},
})

0 comments on commit 3a478ef

Please sign in to comment.