NuxtN
Nuxt13mo ago
5 replies
bryce

Saving an `ArrayBuffer` with `defineCachedEventHandler` & NuxtHub cache

I'm trying to return an ArrayBuffer (with an image) from my cached event handler.

This is working correctly with a regular handler, but with caching it returns
{}
, presumably because useStorage.set is used in cached functions instead of experimental setItemRaw.

Is there any way around this?

I thought of declaring a custom storage provider which only handles array buffers, but if I override the
cache
storage driver I'll override it for all of them?

I suppose I could wrap the NuxtHub cache driver, and detect ArrayBuffers with some more complex serialization but this seems very complicated?
Was this page helpful?