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(routing): add error handling section #2733

Merged
merged 2 commits into from
Sep 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/1.guide/0.index.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ The `routes/` directory contains your application handlers. You can create subdi

### `api/`

The `api/` directory is similar to `routes/` with only difference that routes inside it will be prefixed with `/api/` for convenience.
The `api/` directory is similar to `routes/` with the main difference that routes inside it will be prefixed with `/api/` for convenience.
horvbalint marked this conversation as resolved.
Show resolved Hide resolved

:read-more{to="/guide/routing"}

Expand Down
5 changes: 5 additions & 0 deletions docs/1.guide/2.routing.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ Some providers like Vercel use a top-level `api/` directory as a feature, theref
You will have to use `routes/api/`.
::

#### Differences between the two directories
The `api/` directory is mainly for convenience, routes inside it will be prefixed with `/api/`.

A notable difference between the two directories is how errors are handled by default: in `routes/` they are sent back with with a `Content-Type` of `text/html`, while in `api/` with `application/json`. This behaviour is overridden by some request properties (eg.: `Accept` or `User-Agent` headers).
horvbalint marked this conversation as resolved.
Show resolved Hide resolved

### Simple routes

First, create a file in `routes/` or `api/` directory. The filename will be the route path.
Expand Down