New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

unplugin-cloudflare-headers

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unplugin-cloudflare-headers

Generates cloudflare compatible headers with _headers file

latest
Source
npmnpm
Version
0.3.3
Version published
Maintainers
1
Created
Source

unplugin-cloudflare-headers

NPM version

Install

npm i unplugin-cloudflare-headers

Usage

Vite

// vite.config.ts
import CloudflareHeaders from 'unplugin-cloudflare-headers/vite'

export default defineConfig({
  plugins: [
    CloudflareHeaders({ /* options */ }),
  ],
})
Rollup
// rollup.config.js
import CloudflareHeaders from 'unplugin-cloudflare-headers/rollup'

export default {
  plugins: [
    CloudflareHeaders({ /* options */ }),
  ],
}


Webpack
// webpack.config.js
module.exports = {
  /* ... */
  plugins: [
    require('unplugin-cloudflare-headers/webpack')({ /* options */ })
  ]
}


esbuild
// esbuild.config.js
import { build } from 'esbuild'
import CloudflareHeaders from 'unplugin-cloudflare-headers/esbuild'

build({
  plugins: [CloudflareHeaders()],
})


Options

Top level keys of the options are route definitions. Each route should have an array of headers. Header is simple object, where key is header name and value (string or false) is header value. Let's see example.

This options:

const options = {
  '/*': [{ 'x-testing': 'hello 🌐' }],
  '/admin': [{ 'x-testing': false }]
  // use `false` as header value to detach header from specific route
}

will result into this _headers file:

/*
	x-testing: hello 🌐
/admin
	! x-testing

More on _headers file in cloudflare docs

License MIT

Keywords

unplugin

FAQs

Package last updated on 20 Jul 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts