-
Notifications
You must be signed in to change notification settings - Fork 43
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Version
module: 1.13.3
nuxt: 3.11.2
Nuxt configuration
export default defineNuxtConfig({
devtools: { enabled: false },
modules: ['@nuxtjs/sanity', '@nuxtjs/tailwindcss'],
sanity: {
projectId: '<removed>',
dataset: 'production',
apiVersion: '2022-12-30',
useCdn: false
},
ssr: false,
});Reproduction
⚠️ without a minimal reproduction we wont be able to look into your issue
Link:
[ ] https://stackblitz.com/edit/nuxt-sanity
[ ] GitHub repository
What is expected?
When useCdn is set to false in the config, we expect the client to use api.sanity.io as API-url in production (with nuxt build).
What is actually happening?
The client uses apicdn.sanity.io in production, even if useCdn is set to false. The reason can be found in this code:
sanity/src/runtime/composables/useSanity.ts
Lines 49 to 54 in 93df827
| if (!options.disableSmartCdn && nuxtApp.$preview) { | |
| options.useCdn = false | |
| } | |
| else if (!import.meta.dev && !options.useCdn && !options.token) { | |
| options.useCdn = true | |
| } |
The bug is in this line:
if (!import.meta.dev && !options.useCdn && !options.token) {The !options.useCdn will return true when useCdn is set to false. This should probably be something like this:
if (!import.meta.dev && options.useCdn === undefined && !options.token) {I tried making this change locally, and can confirm that it works like expected now.
Steps to reproduce
Additional information
Checklist
- I have tested with the latest Nuxt version and the issue still occurs
- I have tested with the latest module version and the issue still occurs
- I have searched the issue tracker and this issue hasn't been reported yet
Steps to reproduce
- Create a basic project with Nuxt + Sanity
- Set
useCdntofalse - Build the project and check the URL that is requested
rylanharper
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working