Skip to content

Commit

Permalink
docs: Add pageExtensions usage note in API Routes (#35918)
Browse files Browse the repository at this point in the history
In order to turn the API Routes docs more clear about the file extensions when using `pageExtensions`.
I know that it was already explained [here](https://nextjs.org/docs/api-reference/next.config.js/custom-page-extensions).

But just think about the DX: If a developer have a trouble with an API endpoint not working properly should it check it on custom-page-extensions page or api-routes page itself??

Related to #8178.

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [x] Make sure the linting passes by running `yarn lint`


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
  • Loading branch information
menosprezzi and ijjk committed May 22, 2022
1 parent afbc511 commit 3bd42b4
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/api-routes/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ export default function handler(req, res) {
}
```

> **Note**: API Routes will be affected by [`pageExtensions` configuration](/docs/api-reference/next.config.js/custom-page-extensions.md) in `next.config.js`.
For an API route to work, you need to export a function as default (a.k.a **request handler**), which then receives the following parameters:

- `req`: An instance of [http.IncomingMessage](https://nodejs.org/api/http.html#class-httpincomingmessage), plus some [pre-built middlewares](/docs/api-routes/api-middlewares.md)
Expand Down

0 comments on commit 3bd42b4

Please sign in to comment.