Skip to content

Latest commit

 

History

History
24 lines (15 loc) · 1.18 KB

File metadata and controls

24 lines (15 loc) · 1.18 KB

Edge Middleware

Build Output API

This Prebuilt Deployment example demonstrates how to output Vercel Middleware using the Build Output API.

Demo

https://build-output-api-edge-middleware.vercel.sh

How it Works

In this case, the contents of the Edge Middleware Function are located in the .vercel/output/functions/_middleware.func directory. An accompanying "route" is placed in the config.json file which specifies that the middleware function will be invoked for every HTTP request due to the "src": "/(.*)" clause.

The .vc-config.json file specifies "runtime": "edge" which informs Vercel that the endpoint should be created as an Edge Function.

The "entrypoint": "index.js" field indicates that the index.js source code file will export an Edge Middleware Function that processes each request.

The middleware function adds an HTTP response header for every HTTP request with x-modified-edge: true.