@cfpreview/pages-plugins-headers
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i @cfpreview/pages-plugins-headers

Weekly Downloads

169

Version

0.1.1

License

none

Unpacked Size

13.3 kB

Total Files

5

Last publish

Collaborators

  • gregbrimble
  • 1000hz
  • geelen