|
| 1 | +/** |
| 2 | + * HTTP Headers Configuration for Cloudflare Pages |
| 3 | + * This file is the source of truth for static/_headers generation |
| 4 | + * Run: npm run build:headers |
| 5 | + * |
| 6 | + * Note: This file lives in scripts/ (not static/) to avoid deploying |
| 7 | + * TypeScript source files to production. |
| 8 | + */ |
| 9 | + |
| 10 | +interface HeadersConfig { |
| 11 | + paths: Array<{ |
| 12 | + pattern: string; |
| 13 | + headers: Record<string, string | Record<string, string[]>>; |
| 14 | + }>; |
| 15 | +} |
| 16 | + |
| 17 | +const config: HeadersConfig = { |
| 18 | + paths: [ |
| 19 | + { |
| 20 | + pattern: '/*', |
| 21 | + headers: { |
| 22 | + 'Content-Security-Policy': { |
| 23 | + 'connect-src': [ |
| 24 | + '\'self\'', |
| 25 | + 'https://status.maxmind.com', |
| 26 | + 'https://www.maxmind.com', |
| 27 | + 'https://api.hubspot.com', |
| 28 | + 'https://static.hsappstatic.net', |
| 29 | + 'https://*.googleapis.com', |
| 30 | + 'https://*.google-analytics.com', |
| 31 | + 'https://*.analytics.google.com', |
| 32 | + 'https://*.googletagmanager.com', |
| 33 | + 'https://*.g.doubleclick.net', |
| 34 | + 'https://*.google.com', |
| 35 | + ], |
| 36 | + 'default-src': [ |
| 37 | + '\'self\'', |
| 38 | + ], |
| 39 | + 'font-src': [ |
| 40 | + '\'self\'', |
| 41 | + 'https://fonts.gstatic.com', |
| 42 | + ], |
| 43 | + 'form-action': [ |
| 44 | + '\'self\'', |
| 45 | + ], |
| 46 | + 'frame-ancestors': [ |
| 47 | + '\'self\'', |
| 48 | + ], |
| 49 | + 'frame-src': [ |
| 50 | + '\'self\'', |
| 51 | + 'https://app.hubspot.com', |
| 52 | + 'https://www.google.com', |
| 53 | + 'https://www.googletagmanager.com', |
| 54 | + ], |
| 55 | + 'img-src': [ |
| 56 | + '\'self\'', |
| 57 | + 'data:', |
| 58 | + 'https:', |
| 59 | + ], |
| 60 | + 'object-src': [ |
| 61 | + '\'none\'', |
| 62 | + ], |
| 63 | + 'script-src': [ |
| 64 | + '\'self\'', |
| 65 | + '\'report-sample\'', |
| 66 | + '\'unsafe-inline\'', |
| 67 | + 'https://js.hs-scripts.com', |
| 68 | + 'https://js.hs-analytics.net', |
| 69 | + 'https://js.hs-banner.com', |
| 70 | + 'https://js.usemessages.com', |
| 71 | + 'https://www.maxmind.com', |
| 72 | + 'https://cloud.google.com', |
| 73 | + 'https://www.gstatic.com', |
| 74 | + 'https://www.googleadservices.com', |
| 75 | + 'https://www.google.com', |
| 76 | + 'https://*.googletagmanager.com', |
| 77 | + ], |
| 78 | + 'style-src': [ |
| 79 | + '\'self\'', |
| 80 | + '\'unsafe-inline\'', |
| 81 | + 'https://fonts.googleapis.com', |
| 82 | + 'https://www.gstatic.com', |
| 83 | + ], |
| 84 | + }, |
| 85 | + 'Feature-Policy': |
| 86 | + 'accelerometer \'none\'; autoplay \'none\'; camera \'none\'; ' + |
| 87 | + 'encrypted-media \'none\'; fullscreen \'none\'; geolocation \'none\'; ' + |
| 88 | + 'gyroscope \'none\'; magnetometer \'none\'; microphone \'none\'; ' + |
| 89 | + 'midi \'none\'; payment \'none\'; picture-in-picture \'none\'; ' + |
| 90 | + 'usb \'none\'; sync-xhr \'none\'', |
| 91 | + 'Permissions-Policy': |
| 92 | + 'accelerometer=(), ambient-light-sensor=(), autoplay=(), ' + |
| 93 | + 'battery=(), camera=(), display-capture=(), document-domain=(), ' + |
| 94 | + 'encrypted-media=(), execution-while-not-rendered=(), ' + |
| 95 | + 'execution-while-out-of-viewport=(), fullscreen=(), gamepad=(), ' + |
| 96 | + 'geolocation=(), gyroscope=(), hid=(), idle-detection=(), ' + |
| 97 | + 'magnetometer=(), microphone=(), midi=(), payment=(), ' + |
| 98 | + 'picture-in-picture=(), publickey-credentials-get=(), ' + |
| 99 | + 'screen-wake-lock=(), serial=(), speaker-selection=(), usb=(), ' + |
| 100 | + 'web-share=(), xr-spatial-tracking=()', |
| 101 | + 'Referrer-Policy': 'strict-origin-when-cross-origin', |
| 102 | + 'Strict-Transport-Security': |
| 103 | + 'max-age=63072000; includeSubDomains; preload', |
| 104 | + 'X-Content-Type-Options': 'nosniff', |
| 105 | + 'X-Frame-Options': 'DENY', |
| 106 | + 'X-XSS-Protection': '1; mode=block', |
| 107 | + }, |
| 108 | + }, |
| 109 | + ], |
| 110 | +}; |
| 111 | + |
| 112 | +export default config; |
0 commit comments