Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/logotip4ik/nuxt-cloudflare-headers
Auto generate cloudflare headers with Nuxt3
https://github.com/logotip4ik/nuxt-cloudflare-headers
cloudflare headers nuxt3
Last synced: 2 days ago
JSON representation
Auto generate cloudflare headers with Nuxt3
- Host: GitHub
- URL: https://github.com/logotip4ik/nuxt-cloudflare-headers
- Owner: logotip4ik
- License: mit
- Created: 2022-07-09T11:31:48.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-02-03T19:32:21.000Z (almost 2 years ago)
- Last Synced: 2024-11-10T20:36:54.191Z (9 days ago)
- Topics: cloudflare, headers, nuxt3
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@logotip4ik_/nuxt-cloudflare-headers
- Size: 424 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# โ Nuxt3 Cloudflare Headers
[![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]> Cloudflare headers Module for Nuxt3
[๐ **Release Notes**](https://github.com/logotip4ik/nuxt-cloudflare-headers/releases)
## Features
- ๐ Easy to use
- โ Nuxt3 compatible
- ๐งพ Supports static generation## Setup
1. Add `@logotip4ik_/nuxt-cloudflare-headers` dependency to your project
```bash
yarn add @logotip4ik_/nuxt-cloudflare-headers # or npm install @logotip4ik_/nuxt-cloudflare-headers
```2. Add `@logotip4ik_/nuxt-cloudflare-headers` to the `modules` section of `nuxt.config.js`
```js
// nuxt.config.js
import { defineNuxtConfig } from "nuxt";
import cloudflareHeaders from "@logotip4ik_/nuxt-cloudflare-headers";export default defineNuxtConfig({
modules: [
// With inlined options
[cloudflareHeaders, { "/api": { "x-powered-by": "cloudflare" } }],
],
});
```Or a separate section `nuxt-cloudflare-headers` for module options:
```js
// nuxt.config.js
import { defineNuxtConfig } from "nuxt";
import cloudflareHeaders from "@logotip4ik_/nuxt-cloudflare-headers";export default defineNuxtConfig({
modules: [cloudflareHeaders],cloudflareHeaders: {
"/*": { "some-cool": "header" },
},
});
```## Documentation
```js
// nuxt.config.js
import { defineNuxtConfig } from "nuxt";
import cloudflareHeaders from "@logotip4ik_/nuxt-cloudflare-headers";export default defineNuxtConfig({
modules: [cloudflareHeaders],cloudflareHeaders: {
"/*": { "some-cool": "header", "hello": "world" },
"/admin": { "some-cool": false }, // detaching `some-cool` header from admin route
},
});
```In `cloudflareHeaders` object key (`/*`, `/admin`) will be route matcher and array of objects or plain object will be actual header rules. Where `some-cool` will be header name and `header` will be header value. Also you can detach a header from route by providing `false` as value. So if you are generating your project with such a config, nuxt will prerender `_headers` file with this content inside:
```text
/*
some-cool: header
hello: world/admin
! some-cool
```> For more features read [cloudflare docs about `_headers` file](https://developers.cloudflare.com/pages/platform/headers)
## Development
1. Clone this repository
2. Run `npm run dev:prepare` to generate type stubs.
3. Use `npm run dev` to start [playground](./playground) in development mode.## License
[MIT License](./LICENSE)
[npm-version-src]: https://img.shields.io/npm/v/@logotip4ik_/nuxt-cloudflare-headers/latest.svg
[npm-version-href]: https://npmjs.com/package/@logotip4ik_/nuxt-cloudflare-headers
[npm-downloads-src]: https://img.shields.io/npm/dt/@logotip4ik_/nuxt-cloudflare-headers.svg
[npm-downloads-href]: https://npmjs.com/package/@logotip4ik_/nuxt-cloudflare-headers