Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON file content returned as binary instead of json if sent as nested response #2217

Closed
manniL opened this issue Mar 4, 2024 · 5 comments · Fixed by #2229 or #2239
Closed

JSON file content returned as binary instead of json if sent as nested response #2217

manniL opened this issue Mar 4, 2024 · 5 comments · Fixed by #2229 or #2239
Labels
bug Something isn't working

Comments

@manniL
Copy link
Member

manniL commented Mar 4, 2024

Environment

Stackblitz

Reproduction

  1. https://stackblitz.com/edit/nitro-issues-2217
  2. Start dev - all fine
  3. Run npm run build && node .output/server/index.mjs
  4. See the UInt8 content

image

Describe the bug

When fetching a JSON file via server assets (useStorage) and return it as a wrapped object (e.g. { item }), it is not returned as content but as UInt8 array.

This didn't happen before.

Additional context

Introduced via 60eb9f6 / #2107

Logs

No response

@manniL manniL changed the title JSON file returned as UInt8 array instead of content if sent as nested response JSON file content returned as binary instead of json if sent as nested response Mar 4, 2024
@pi0 pi0 added bug Something isn't working and removed pending triage labels Mar 4, 2024
@farnabaz
Copy link
Contributor

farnabaz commented Mar 7, 2024

I think we can add .json, .csv and .yaml to raw plugin extensions

const extensions = new Set([
".md",
".mdx",
".yml",
".txt",
".css",
".htm",
".html",
...(opts.extensions || []),
]);

Or maybe make it configurable.

!Content module broken with latest nitro nuxt/content#2580

@pi0
Copy link
Member

pi0 commented Mar 7, 2024

Feel free to make a PR adding more known extensions 🙏 (also you can make sure in usage to always convert to string with .toString(utc8))

@dargmuesli
Copy link
Contributor

Hmm, now routes called something.json can only serve static content anymore and can not be handled by something.json.ts?

Seems breaking: dargmuesli/creal#442
See nuxt-modules/og-image#172 cc @harlan-zw

Should this be a created as a new issue?

@pi0
Copy link
Member

pi0 commented Mar 9, 2024

A new issue with minimal nitro reproduction would be helpful 🙏

@dargmuesli
Copy link
Contributor

dargmuesli commented Mar 9, 2024

Couldn't reproduce in plain nitro, so I've created a bug ticket for Nuxt instead: nuxt/nuxt#26168

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
4 participants