docs(routing): add error handling section #2733
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
π Linked issue
β Type of change
π Description
While migrating some servers to Nitro (in Nuxt), I came across an odd behaviour that took some time to unveil. For some of the routes errors were handled correctly, while for others the client could not determine the error type. With some trial and error I figured out, that there is a difference between how an error is sent back to the client depening on which route directory the route is placed.
The
routes/
dir uses a Content-Type oftext/html
, while theapi/
dirapplication/json
by default. In this PR I tried to clarify this in the docs, wich previously stated that the only difference is the/api/
prefix.As a side note I would be very interested, in the reasoning behind this behaviour. I feel like it is quite footgun-y, while I don't see the benefits.
π Checklist