docs(server): add example for early spiking middleware (#3564)

This commit is contained in:
Alexander Lichter 2022-03-09 14:42:42 +01:00 committed by GitHub
parent 20f31712c1
commit a55c7874e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 0 deletions

View File

@ -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) More information about custom middleware can be found in the documentation for [nuxt.config.js](/docs/directory-structure/nuxt.config#servermiddleware)