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

The built-in error handler over-assumes json request type #1919

Closed
passionate-bram opened this issue Nov 17, 2023 · 0 comments · Fixed by #1921
Closed

The built-in error handler over-assumes json request type #1919

passionate-bram opened this issue Nov 17, 2023 · 0 comments · Fixed by #1921

Comments

@passionate-bram
Copy link
Contributor

Environment

Affects latest version of nitro, the project I am working on has nitropack@2.7.2.

Reproduction

Stackblitz minimal example

Describe the bug

Preconditions:

  • An error occurs during request handling (e.g. throw createError({statusCode:500,statusMessage:'SomeError'}))
  • The default nitro error handler is used.
  • The request is made with the Fetch API; but really: the request has sec-fetch-mode set to cors.

Then the request over-assumes that the request is JSON, and sending an Accept header set to text/html does not coerce the response to HTML, it remains JSON.

Additional context

The related check in isJsonRequest

Logs

Not relevant
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant