#How to use server assets

4 messages · Page 1 of 1 (latest)

crimson bronzeBOT
#

Hi @nimble storm. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

There isn’t a detailed section in the provided docs specifically about serverAssets, so I have to infer from the general Nitro storage docs and examples.

From the Nuxt 3/4 server docs, Nitro exposes a storage layer and you access storages with useStorage('<name>'). Custom storages (like Redis) are configured under nitro.storage and then accessed by that name. [Server dir]

However, the knowledge sources you provided:

  • Show how to configure nitro.storage (e.g. redis) and then use useStorage('redis'). [Server dir]
  • Do not show any example of nitro.serverAssets or of using useStorage('assets:<baseName>').

Because of that, I cannot confirm from the docs that:

  • serverAssets is the correct key in nuxt.config for Nuxt 3/4, or
  • that the storage name is indeed assets:<baseName> (e.g. assets:templates), or
  • what the correct path/key format for getItemRaw / getKeys is in this case.

All I can say with confidence from the docs is:

  1. For custom storages configured under nitro.storage, you must use the exact key you configured:

    export default defineNuxtConfig({
      nitro: {
        storage: {
          redis: {
            driver: 'redis',
            // ...
          }
        }
      }
    })
    

    and then:

    const storage = useStorage('redis')
    const keys = await storage.getKeys()
    

    [Server dir]

  2. The docs do not describe serverAssets or the assets: storage namespace, so I cannot verify that useStorage('assets:templates') is the correct name or that ./templates is being picked up.

Given this limitation, the most likely reasons for null / [] are:

#
  • The storage name is not actually assets:templates (but the docs here don’t say what it should be).
  • The serverAssets option is not correctly configured or not supported as you’re using it.
  • The path/key you’re passing to getItemRaw ('test.docx') does not match how Nitro indexes those assets.

But I cannot provide the exact correct configuration or usage from the supplied sources.

To move forward, you’d need to check Nitro’s own serverAssets / storage docs (https://nitro.build/config and storage docs) or Nuxt’s latest Nitro config docs beyond what’s included here, because the provided knowledge sources do not contain enough information to answer this precisely.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

@nimble storm Kapa.ai is still learning and improving, please let me know how I did by reacting below.