createMiddleware
Edit this pagecreateMiddleware
creates a configuration object for SolidStart that specifies when middleware functions are executed during the request lifecycle.
There are two lifecycle events available: onRequest
and onBeforeResponse
.
- The
onRequest
event is triggered at the beginning of the request lifecycle, before the request is handled by the route handler. - The
onBeforeResponse
event is triggered after a request has been processed by the route handler but before the response is sent to the client.
Note
SolidStart will only execute the middleware functions if the path to the middleware file is configured within app.config.ts
using the middleware
option.
This file must export the configuration using export default
.
Learn more about middleware in the Middleware documentation.
Parameters
createMiddleware
takes an object with the following keys:
onRequest
(optional): A middleware function or an array of functions to execute at theonRequest
event. If an array is provided, the middleware functions will be executed one by one, in the order they appear in the array.onBeforeResponse
(optional): A middleware function or an array of functions to execute at theonBeforeResponse
event. If an array is provided, the middleware functions will be executed one by one, in the order they appear in the array.