Skip to content

Commit

Permalink
docs(routing): add note about middleware returns (#1884)
Browse files Browse the repository at this point in the history
  • Loading branch information
oof2win2 committed Nov 6, 2023
1 parent b3dbcb2 commit c5cfca1
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion docs/content/1.guide/3.routing.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ nitro.config.ts
### Simple Middleware

Middleware are defined exactly like route handlers with the only exception that they should not return anything.
Returning from middleware behaves like returning from a request - the value will be returned as a response and further code will not be ran.

```ts [middleware/auth.ts]
export default defineEventHandler((event) => {
Expand All @@ -181,7 +182,7 @@ export default defineEventHandler((event) => {
```

::alert
Returning anything from a middleware will close the request and should be avoided!
Returning anything from a middleware will close the request and should be avoided! Any returned value from middleware will be the response and further code will not be executed however **this is not recommended to do!**
::

### Execution Order
Expand Down

0 comments on commit c5cfca1

Please sign in to comment.