Skip to content

Commit

Permalink
Clarify the differences between the two route directories
Browse files Browse the repository at this point in the history
  • Loading branch information
horvbalint committed Sep 12, 2024
1 parent e28a02f commit 4686bba
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
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.

: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).

### Simple routes

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

0 comments on commit 4686bba

Please sign in to comment.