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

docs: error handling #2733

Open
wants to merge 2 commits into
base: v2
Choose a base branch
from
Open

Conversation

horvbalint
Copy link

πŸ”— Linked issue

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme, or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to 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 of text/html, while the api/ dir application/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

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

docs/1.guide/2.routing.md Outdated Show resolved Hide resolved
docs/1.guide/0.index.md Outdated Show resolved Hide resolved
@horvbalint
Copy link
Author

@pi0 Thanks for the quick response! I went to sleep sorry πŸ˜ƒ

I tried to fix the docs according your comments. I found no appropriate place for this note in the current docs, so I created an 'Error handling' section in the routing guide (similar how it is in the H3 docs). Hopefully this is ok :)

Can you tell me the reasoning behind this route path based content type behaviour?

@horvbalint horvbalint changed the title docs: clarify the differences between the two route directories docs: error handling Sep 13, 2024
@horvbalint horvbalint requested a review from pi0 September 17, 2024 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants