Middleware
// a function which accepts an event object and a next() function.
type Middleware = (
event: OutsmartlyMiddlewareEvent,
next: (request?: Request) => Promise<Response>,
) => PromiseOrValue<Response>;
type PromiseOrValue<T> = Promise<T> | T;function exampleMiddleware(event, next) {
return next();
}export default {
host: 'example.outsmartly.app',
environments: [
{
name: 'production',
origin: 'https://my-example-website.vercel.app',
},
],
// All routes will have this middleware applied
middleware: [
function firstMiddleware(event, next) {
return next();
},
],
routes: [
{
// Any paths that start with /some-base-path/ will have
// this middleware applied.
path: '/some-base-path/*',
middleware: [
function secondMiddleware(event, next) {
return next();
},
],
},
],
};Examples
Set a cookie
Redirects
Last updated
Was this helpful?