nitro icon indicating copy to clipboard operation
nitro copied to clipboard

useStorage().getItem() - different behaviour locally and on vercel

Open nstdspace opened this issue 3 months ago • 2 comments

Environment

Node: 20.14.0 Nitro(pack): 2.9.6

Reproduction

  • Create a new nitro app via npx giget@latest nitro nitro-app --install
  • Create the directory server/assets
  • Add a file named "x" with any content
  • Inside of the index event handler, replace the default content with
const storage = useStorage("assets:server");
return storage.getItem("x");

Reproduction repository, at commit getKeys() - 7d602f06b3ae2b87cbfdefff5ac58614fa6579f1

Describe the bug

In the case described above, locally I get a response with the content of x with the response header content-type: text/html. Deployed on Vercel, however, I get an empty response (204). In fact, returning getKeys() instead returns ['x'] locally but an empty array ([]) deployed on vercel.

This seems like a bug to me, so I preferred this example. The original problem I observed was something I cannot reproduce with nitro only: I have a file called x.b64 in a nuxt project. Locally, getItem returns just the content of the file in a string. On vercel I get an object looking like { "0": x, "1": y ...} with as many entries as there are bytes in the file and result[I] = byte at index i.

It seems to me that either vercel or nitro does something weird depending on the file ending, but I don't see exactly what.

Reading a pdf file produces a response with content type text/html but application/pdf on vercel (although the same content).

Where are those inconsistencies coming from?

Additional context

No response

Logs

No response

nstdspace avatar May 30 '24 10:05 nstdspace