nuxt-multi-cache icon indicating copy to clipboard operation
nuxt-multi-cache copied to clipboard

Cannot destructure property 'serverOptions' of 'useMultiCacheApp(...)' as it is undefined.

Open lukas-kreuzer opened this issue 1 year ago • 1 comments

Hi there,

With the update from the version 3.2.0 to 3.3.0 i get this error when I call the purgeAll endpoint. I have looked through the changes and maybe my error is caused by this line https://github.com/dulnan/nuxt-multi-cache/commit/9bd9d496a13a710c620c5a1b28aa0e98a1b6719d#diff-ad782f9485665dc82c5135d0a2dca0a1b92cbd56a2db995202b5ed5a45344d3dR9 ?

I also noticed, that the debug output is not there anymore altough the debug flag is enabled. Maybe there is something that needs to be changed in order for this version to work? I looked through the docs but did not found anything.

As soon as I downgrade the version, the cache works as intended.

Full Error on Purge All:

{"url":"/cache/purge/all","statusCode":500,"statusMessage":"","message":"Cannot destructure property 'serverOptions' of 'useMultiCacheApp(...)' as it is undefined.","stack":"<pre><span class=\"stack internal\">at checkAuth (./node_modules/nuxt-multi-cache/dist/runtime/server/api/helpers/index.js:19:11)</span>\n<span class=\"stack internal\">at Object.handler (./node_modules/nuxt-multi-cache/dist/runtime/server/api/purgeAll.js:5:9)</span>\n<span class=\"stack internal\">at Object.handler (./node_modules/h3/dist/index.mjs:2213:34)</span>\n<span class=\"stack internal\">at ./node_modules/h3/dist/index.mjs:1975:31</span>\n<span class=\"stack internal\">at process.processTicksAndRejections (node:internal/process/task_queues:95:5)</span>\n<span class=\"stack internal\">at async Object.callAsync (./node_modules/unctx/dist/index.mjs:72:16)</span>\n<span class=\"stack internal\">at async Server.toNodeHandle (./node_modules/h3/dist/index.mjs:2266:7)</span></pre>"}

lukas-kreuzer avatar Aug 07 '24 07:08 lukas-kreuzer

I'm pretty sure this is related to #69 where the nitro plugin that injects the property on the nitro app was only included if either the route or the cdn feature was enabled. So having just data or component enabled would result in this issue.

dulnan avatar Aug 25 '24 07:08 dulnan

Should be fixed in the latest release.

dulnan avatar Nov 15 '24 07:11 dulnan