I am currently developing a Nuxt3 project and I'm looking to integrate a script provided by Axeptio, a cookie platform.
To achieve this integration, I created a custom plugin in Nuxt3.
export default defineNuxtPlugin((useNuxtApp) => {
;(<any>window).axeptioSettings = {
clientId: '...',
cookiesVersion: '...',
}
;(function (d, s) {
var t:any = d.getElementsByTagName(s)[0],
e: any = d.createElement(s)
e.async = true
e.src = '//static.axept.io/sdk.js'
t.parentNode.insertBefore(e, t)
})(document, 'script')
})
However, when I tried implementing the code, I encountered an error:
Uncaught TypeError: Cannot read properties of undefined (reading 'REACT_APP_SC_ATTR')
Surprisingly, the same code worked perfectly fine in Nuxt2. Any suggestions on how to resolve this issue in Nuxt3?