Skip to content

Latest commit

 

History

History
 
 

headers

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

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][]).