Skip to content

Commit 68faefa

Browse files
committed
fix: enable useCdn at runtime if no token is available
1 parent 1f542a0 commit 68faefa

2 files changed

Lines changed: 2 additions & 4 deletions

File tree

src/module.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,6 @@ export default defineNuxtModule<SanityModuleOptions>({
139139
...getDefaultSanityConfig(resolve(nuxt.options.rootDir, './sanity.json')),
140140
}),
141141
async setup (options, nuxt) {
142-
if (!('useCdn' in options)) {
143-
options.useCdn = process.env.NODE_ENV === 'production' && !options.token
144-
}
145-
146142
if (options.visualEditing) {
147143
try {
148144
if (options.minimal) {

src/runtime/composables/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ export const useSanity = (client = 'default'): SanityHelper => {
4242

4343
if (!options.disableSmartCdn && nuxtApp.$preview) {
4444
options.useCdn = false
45+
} else if (!import.meta.dev && !options.useCdn && !options.token) {
46+
options.useCdn = true
4547
}
4648

4749
if (client === 'default') {

0 commit comments

Comments
 (0)