Skip to content

Commit

Permalink
docs(server): add example for early spiking middleware (nuxt#3564)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheAlexLichter authored Mar 9, 2022
1 parent 20f3171 commit a55c787
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions docs/content/3.docs/2.directory-structure/13.server.md
Original file line number Diff line number Diff line change
@@ -89,4 +89,17 @@ export default async (req: IncomingMessage, res: ServerResponse) => {
}
```

To pass the request deeper into the application, you can simply `return` inside the function:

```js
export default async (req, res) => {
const isNotHandledByThisMiddleware = req.url.includes('/some-unhandled-url-path/')
if(isNotHandledByThisMiddleware) {
return
}

// Actual logic here
}
```

More information about custom middleware can be found in the documentation for [nuxt.config.js](/docs/directory-structure/nuxt.config#servermiddleware)

0 comments on commit a55c787

Please sign in to comment.