Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/logotip4ik/unplugin-cloudflare-headers
Generate ☁cloudflare headers
https://github.com/logotip4ik/unplugin-cloudflare-headers
Last synced: 16 days ago
JSON representation
Generate ☁cloudflare headers
- Host: GitHub
- URL: https://github.com/logotip4ik/unplugin-cloudflare-headers
- Owner: logotip4ik
- License: mit
- Created: 2022-11-03T20:44:29.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2024-01-19T23:43:42.000Z (10 months ago)
- Last Synced: 2024-10-19T19:40:13.589Z (about 1 month ago)
- Language: TypeScript
- Size: 254 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# unplugin-cloudflare-headers
[![NPM version](https://img.shields.io/npm/v/unplugin-cloudflare-headers?color=a1b858&label=)](https://www.npmjs.com/package/unplugin-cloudflare-headers)
## Install
```bash
npm i unplugin-cloudflare-headers
```## Usage
Vite
```ts
// vite.config.ts
import CloudflareHeaders from 'unplugin-cloudflare-headers/vite'export default defineConfig({
plugins: [
CloudflareHeaders({ /* options */ }),
],
})
```Rollup
```ts
// rollup.config.js
import CloudflareHeaders from 'unplugin-cloudflare-headers/rollup'export default {
plugins: [
CloudflareHeaders({ /* options */ }),
],
}
```
Webpack
```ts
// webpack.config.js
module.exports = {
/* ... */
plugins: [
require('unplugin-cloudflare-headers/webpack')({ /* options */ })
]
}
```
esbuild
```ts
// 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:
```js
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:
```text
/*
x-testing: hello 🌐
/admin
! x-testing
```More on `_headers` file in [cloudflare docs](https://developers.cloudflare.com/pages/platform/headers)
License [MIT](./LICENSE)