@cfpreview/pages-plugins-headers
v0.1.1
Published
# Headers
Downloads
691
Readme
Pages Plugins
Headers
This headers plugin adds headers to all responses which occur below it in the execution chain.
Installation
npm install --save @cfpreview/pages-plugins-headers
Usage
// ./functions/api/_middleware.ts
import headersPlugin from "@cfpreview/pages-plugins-headers";
export const onRequest: PagesFunction = headersPlugin({
"Access-Control-Allow-Origin": "*",
});
The plugin takes the same argument as the new Headers()
constructor:
- a
Headers
instance, - an object of header names mapping to header values (i.e.
Record<string, string>
), or - an array of header name, header value pairs (i.e.
[string, string][]
).