dystcz / nuxt-sanctum-auth

Nuxt 3 + laravel sanctum authentication
135 stars 25 forks source link

Error 500 Cannot redefine property: $apiFetch #3

Closed krugerdavid closed 1 year ago

krugerdavid commented 1 year ago

Trying to use this module on a nuxt3 but after including the module on nuxt.config.js got this error.

500
Cannot redefine property: $apiFetch

at Function.defineProperty ()
at defineGetter (http://localhost:3000/_nuxt/node_modules/nuxt/dist/app/nuxt.mjs?v=ea545e68:164:10)
at nuxtApp.provide (http://localhost:3000/_nuxt/node_modules/nuxt/dist/app/nuxt.mjs?v=ea545e68:49:5)
at http://localhost:3000/_nuxt/plugins/apiFetch.js:6:13
at fn (http://localhost:3000/_nuxt/node_modules/nuxt/dist/app/nuxt.mjs?v=ea545e68:141:27)
at callWithNuxt (http://localhost:3000/_nuxt/node_modules/nuxt/dist/app/nuxt.mjs?v=ea545e68:146:12)
at applyPlugin (http://localhost:3000/_nuxt/node_modules/nuxt/dist/app/nuxt.mjs?v=ea545e68:92:29)
at applyPlugins (http://localhost:3000/_nuxt/node_modules/nuxt/dist/app/nuxt.mjs?v=ea545e68:101:11)
at async initApp (http://localhost:3000/_nuxt/Users/dkruger/Works/iratu/argencredit-front/node_modules/nuxt/dist/app/entry.mjs:39:7)

not sure why is this happening.

kreejzak commented 1 year ago

It looks like you are trying to redefine the provided $apiFetch plugin with some sort of your own plugin called apiFetch. Or maybe some other plugin is used and they are both trying to set the $apiFetch variable.

kreejzak commented 1 year ago

Hello @krugerdavid, was this issue resolved? Thanks

kreejzak commented 1 year ago

Closing for inactivity

krugerdavid commented 1 year ago

Sorry @kreejzak !! there was a plugin messing it around. BTW, is there a way to use this module but where the front manually logins an account? not sure if I'm explaining clearly :D

kreejzak commented 1 year ago

Hey!, I guess it's for dev or testing purposes. You can send login request with predefined dummy data for example in onMounted hook in default layout if loggedIn is false.

But I would advice against it in production.