From a55c7874e6c22a8a927027cbf5f4149a8711525a Mon Sep 17 00:00:00 2001 From: Alexander Lichter Date: Wed, 9 Mar 2022 14:42:42 +0100 Subject: [PATCH] docs(server): add example for early spiking middleware (#3564) --- .../3.docs/2.directory-structure/13.server.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docs/content/3.docs/2.directory-structure/13.server.md b/docs/content/3.docs/2.directory-structure/13.server.md index ef947ea920..3235897912 100644 --- a/docs/content/3.docs/2.directory-structure/13.server.md +++ b/docs/content/3.docs/2.directory-structure/13.server.md @@ -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)