3rd party script blocked by CORS #193
Replies: 2 comments 2 replies
-
|
Hi @AloisSeckar This is due to You can get around this issue by doing scripts: {
globals: {
myScript: ['https://app.termly.io/resource-blocker/bbc9f62b-96e1-4064-bea5-e604bb669e55?autoBlock=on', {
trigger: 'onNuxtReady',
crossorigin: false,
}],
},
},You can read more about this behaviour here: https://unhead.unjs.io/usage/composables/use-script#referrerpolicy-and-crossorigin Let me know if you have any questions or feedback around this 🙂 |
Beta Was this translation helpful? Give feedback.
-
|
For anyone stumbling into this like I did, the correct way to do it is to use an object with const scripts = {
globals: {
myScript: [
{
src: 'https://app.termly.io/resource-blocker/bbc9f62b-96e1-4064-bea5-e604bb669e55?autoBlock=on',
crossorigin: false,
// ... Regular Script Tag Options
},
{
trigger: 'onNuxtReady',
// ... Other Nuxt Scripts Options
},
],
},
} |
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
-
I am trying to call external script of Termly cookie consent service via Nuxt Scripts.
This is what I have in my
nuxt.config.ts:However, the call gets blocked due to CORS:

When I have script referenced from
useHead, it worked with no issues:I am still getting confused with CORS stuff in general. Is there some setting, I need to set up for Nuxt Script module or for Nuxt in general to get this working? Or is it because the target domain refuses my requests due to something I cannot quite affect?
Beta Was this translation helpful? Give feedback.
All reactions