{"id":50607186,"url":"https://github.com/hugo-vrijswijk/astro-headers-file","last_synced_at":"2026-06-06T00:03:51.893Z","repository":{"id":360909070,"uuid":"1252227002","full_name":"hugo-vrijswijk/astro-headers-file","owner":"hugo-vrijswijk","description":"Astro integration that uses existing configuration to write a static headers file for platforms like Cloudflare Pages, Netlify and Vercel.","archived":false,"fork":false,"pushed_at":"2026-05-28T10:30:45.000Z","size":110,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-28T12:16:05.450Z","etag":null,"topics":["astro","astro-integration","cloudflare","headers","netlify","vercel","withastro"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hugo-vrijswijk.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-28T10:06:24.000Z","updated_at":"2026-05-28T10:30:38.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/hugo-vrijswijk/astro-headers-file","commit_stats":null,"previous_names":["hugo-vrijswijk/astro-headers-file"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/hugo-vrijswijk/astro-headers-file","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hugo-vrijswijk%2Fastro-headers-file","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hugo-vrijswijk%2Fastro-headers-file/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hugo-vrijswijk%2Fastro-headers-file/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hugo-vrijswijk%2Fastro-headers-file/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hugo-vrijswijk","download_url":"https://codeload.github.com/hugo-vrijswijk/astro-headers-file/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hugo-vrijswijk%2Fastro-headers-file/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33964367,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-05T02:00:06.157Z","response_time":120,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["astro","astro-integration","cloudflare","headers","netlify","vercel","withastro"],"created_at":"2026-06-06T00:03:51.140Z","updated_at":"2026-06-06T00:03:51.887Z","avatar_url":"https://github.com/hugo-vrijswijk.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# astro-headers-file\n\nAstro integration that uses your existing configuration to write a static headers file for platforms like Cloudflare Pages, Netlify and Vercel, and others.\n\nPicks up your existing headers configuration, as well as your CSP directives, and generates a static headers file in the output directory. The generated file is compatible with the format expected by platforms like Cloudflare Pages, Netlify and Vercel.\n\n## Installation\n\n```bash\nnpm install astro-headers-file -D\n\n# pnpm\npnpm add astro-headers-file -D\n\n# yarn\nyarn add astro-headers-file -D\n```\n\n## Usage\n\nAdd the integration to your `astro.config.ts`:\n\n```ts\nimport { defineConfig } from 'astro/config';\nimport headersFile from 'astro-headers-file';\n\nexport default defineConfig({\n  integrations: [headersFile()],\n  security: {\n    // Add content-security-policy directives with hashes\n    csp: true,\n  },\n  server: {\n    headers: {\n      // Specify per path\n      '/*': [\n        'X-Frame-Options: DENY',\n        'X-Content-Type-Options: nosniff',\n        'Cross-Origin-Opener-Policy: same-origin',\n        'Cross-Origin-Resource-Policy: same-origin',\n        'Referrer-Policy: same-origin',\n        'Cache-Control: public, max-age=60, must-revalidate',\n      ],\n      '/_astro/*': ['Cache-Control: public, max-age=31536000, immutable'],\n      '/': ['Cache-Control: public, max-age=0, must-revalidate'],\n\n      // Or for all paths (uses `/*`)\n      'X-Custom-Header': 'My custom value',\n    },\n  },\n});\n```\n\nAfter running `astro build`, a headers file will be generated in the output directory with the configured headers and CSP directives:\n\n```\n/\n  content-security-policy: script-src 'self' '\u003csha256-hashes\u003e'; style-src 'self' '\u003csha256-hashes\u003e';\n  Cache-Control: public, max-age=0, must-revalidate\n\n/*\n  X-Frame-Options: DENY\n  X-Content-Type-Options: nosniff\n  Cross-Origin-Opener-Policy: same-origin\n  Cross-Origin-Resource-Policy: same-origin\n  Referrer-Policy: same-origin\n  Cache-Control: public, max-age=60, must-revalidate\n  X-Custom-Header: My custom value\n\n/_astro/*\n  Cache-Control: public, max-age=31536000, immutable\n```\n\n\n## Options\n\nThe integration accepts the following options:\n\n| Option             | Type                 | Default                                               | Description                                                                                                                                                      |\n| ------------------ | -------------------- | ----------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `filename`         | string               | `_headers`                                            | Filename for the generated headers file. Relative to the output directory.                                                                                       |\n| `blocklistHeaders` | (string \\| RegExp)[] | `['content-length', 'content-type', 'last-modified']` | Blocklist of headers to exclude from the generated headers file. Can be either a string (exact match) or a RegExp (pattern match). Matching is case-insensitive. |\n| `blocklistPaths`   | (string \\| RegExp)[] | `[]`                                                  | Blocklist of paths to exclude from the generated headers file. Can be either a string (exact match) or a RegExp (pattern match).                                 |\n\n## Does this work with...?\n\n- Cloudflare/Vercel/Netlify? Yes! And any other platform that supports a static headers file in the same format\n- Astro [`security.csp`](https://docs.astro.build/en/reference/configuration-reference/#securitycsp)? Yes! The integration adds all configured CSP directives to the generated headers file.\n- Custom headers in `astro.config.mjs`? Yes! Any custom headers you configure in `astro.config.mjs` will also be included in the generated headers file.\n- `@astrojs/node` adapter? No, the adapter will handle headers at runtime by itself.\n- `@astrojs/cloudflare` adapter? Untested.\n\n## Why not use...?\n\nAlternatives exist, and are great. But this package has some advantages over...:\n\n- [astro-static-headers](https://github.com/abemedia/astro-static-headers): only works with specific adapters, not with static output. This integration has no need to add a separate adapter for your platform.\n- [astro-cloudflare-pages-headers](https://github.com/martinsilha/astro-cloudflare-pages-headers): works mostly the same, but CSP directives do not use the Astro CSP configuration. With this integration you can use the standard Astro CSP configuration and have the directives automatically included in the generated headers file, with support for hashes and nonces.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhugo-vrijswijk%2Fastro-headers-file","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhugo-vrijswijk%2Fastro-headers-file","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhugo-vrijswijk%2Fastro-headers-file/lists"}