Middleware
Edit this pageMiddlewares may be included by passing file you specify in your start config.
import { defineConfig } from "@solidjs/start/config";
export default defineConfig({ middleware: "./src/middleware.ts"});Inside the middleware file, you can export a createMiddleware function.
import { createMiddleware } from "@solidjs/start/middleware";
export default createMiddleware({ onRequest: [ event => { console.log("GLOBAL", event.request.url); } ]});Middleware supports 2 lifecycles: onRequest and onBeforeResponse. If you return a value from middleware it will respond with that, otherwise it will run the next one in the chain.