|
| 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 | + |
| 7 | +interface HeadersConfig { |
| 8 | + paths: Array<{ |
| 9 | + pattern: string; |
| 10 | + headers: Record<string, string[] | Record<string, string[]>>; |
| 11 | + }>; |
| 12 | +} |
| 13 | + |
| 14 | +const config: HeadersConfig = { |
| 15 | + paths: [ |
| 16 | + { |
| 17 | + pattern: '/*', |
| 18 | + headers: { |
| 19 | + 'Content-Security-Policy': { |
| 20 | + 'connect-src': [ |
| 21 | + "'self'", |
| 22 | + 'https://status.maxmind.com', |
| 23 | + 'https://www.maxmind.com', |
| 24 | + |
| 25 | + // eslint-disable-next-line max-len |
| 26 | + // https://knowledge.hubspot.com/domains-and-urls/ssl-and-domain-security-in-hubspot#content-security-policy |
| 27 | + |
| 28 | + // HubSpot API |
| 29 | + 'https://api.hubspot.com', |
| 30 | + |
| 31 | + // HubSpot static assets (conversations embed) |
| 32 | + 'https://static.hsappstatic.net', |
| 33 | + |
| 34 | + 'https://*.googleapis.com', |
| 35 | + |
| 36 | + // eslint-disable-next-line max-len |
| 37 | + // https://developers.google.com/tag-platform/security/guides/csp#google_analytics_4_google_analytics |
| 38 | + 'https://*.google-analytics.com', |
| 39 | + 'https://*.analytics.google.com', |
| 40 | + 'https://*.googletagmanager.com', |
| 41 | + |
| 42 | + // https://developers.google.com/tag-platform/security/guides/csp#google_ads |
| 43 | + 'https://*.g.doubleclick.net', |
| 44 | + |
| 45 | + // Google domains (various TLDs for international support) |
| 46 | + 'https://*.google.com', |
| 47 | + ], |
| 48 | + 'default-src': ["'self'"], |
| 49 | + 'font-src': [ |
| 50 | + "'self'", |
| 51 | + |
| 52 | + // Loaded indirectly by Google Vertex search |
| 53 | + 'https://fonts.gstatic.com', |
| 54 | + ], |
| 55 | + 'form-action': ["'self'"], |
| 56 | + 'frame-ancestors': ["'self'"], |
| 57 | + 'frame-src': [ |
| 58 | + "'self'", |
| 59 | + |
| 60 | + // eslint-disable-next-line max-len |
| 61 | + // https://knowledge.hubspot.com/domains-and-urls/ssl-and-domain-security-in-hubspot#content-security-policy |
| 62 | + |
| 63 | + // HubSpot calls-to-action (pop-ups) and chatflows |
| 64 | + 'https://app.hubspot.com', |
| 65 | + |
| 66 | + // https://developers.google.com/tag-platform/security/guides/csp#google_ads |
| 67 | + 'https://www.googletagmanager.com', |
| 68 | + |
| 69 | + // Google Vertex search |
| 70 | + 'https://www.google.com', |
| 71 | + ], |
| 72 | + 'img-src': ["'self'", 'data:', 'https:'], |
| 73 | + 'object-src': ["'none'"], |
| 74 | + 'script-src': [ |
| 75 | + "'self'", |
| 76 | + "'report-sample'", |
| 77 | + "'unsafe-inline'", |
| 78 | + |
| 79 | + // eslint-disable-next-line max-len |
| 80 | + // https://knowledge.hubspot.com/domains-and-urls/ssl-and-domain-security-in-hubspot#content-security-policy |
| 81 | + |
| 82 | + // HubSpot tracking code |
| 83 | + 'https://js.hs-scripts.com', |
| 84 | + |
| 85 | + // HubSpot Analytics |
| 86 | + 'https://js.hs-analytics.net', |
| 87 | + |
| 88 | + // HubSpot cookie banner |
| 89 | + 'https://js.hs-banner.com', |
| 90 | + |
| 91 | + // HubSpot Conversations and Chatflows |
| 92 | + 'https://js.usemessages.com', |
| 93 | + |
| 94 | + // MaxMind marketing site |
| 95 | + 'https://www.maxmind.com', |
| 96 | + |
| 97 | + // Google Vertex search |
| 98 | + 'https://cloud.google.com', |
| 99 | + 'https://www.gstatic.com', |
| 100 | + |
| 101 | + // https://developers.google.com/tag-platform/security/guides/csp#google_ads_conversions |
| 102 | + 'https://www.googleadservices.com', |
| 103 | + 'https://www.google.com', |
| 104 | + |
| 105 | + // Google Tag Manager |
| 106 | + 'https://*.googletagmanager.com', |
| 107 | + ], |
| 108 | + 'style-src': [ |
| 109 | + "'self'", |
| 110 | + "'unsafe-inline'", |
| 111 | + |
| 112 | + // Google Fonts API and Vertex search default styles |
| 113 | + 'https://fonts.googleapis.com', |
| 114 | + |
| 115 | + // Google static assets |
| 116 | + 'https://www.gstatic.com', |
| 117 | + ], |
| 118 | + }, |
| 119 | + 'Feature-Policy': [ |
| 120 | + "accelerometer 'none'", |
| 121 | + "autoplay 'none'", |
| 122 | + "camera 'none'", |
| 123 | + "encrypted-media 'none'", |
| 124 | + "fullscreen 'none'", |
| 125 | + "geolocation 'none'", |
| 126 | + "gyroscope 'none'", |
| 127 | + "magnetometer 'none'", |
| 128 | + "microphone 'none'", |
| 129 | + "midi 'none'", |
| 130 | + "payment 'none'", |
| 131 | + "picture-in-picture 'none'", |
| 132 | + "usb 'none'", |
| 133 | + "sync-xhr 'none'", |
| 134 | + ], |
| 135 | + 'Permissions-Policy': [ |
| 136 | + 'accelerometer=()', |
| 137 | + 'ambient-light-sensor=()', |
| 138 | + 'autoplay=()', |
| 139 | + 'battery=()', |
| 140 | + 'camera=()', |
| 141 | + 'display-capture=()', |
| 142 | + 'document-domain=()', |
| 143 | + 'encrypted-media=()', |
| 144 | + 'execution-while-not-rendered=()', |
| 145 | + 'execution-while-out-of-viewport=()', |
| 146 | + 'fullscreen=()', |
| 147 | + 'gamepad=()', |
| 148 | + 'geolocation=()', |
| 149 | + 'gyroscope=()', |
| 150 | + 'hid=()', |
| 151 | + 'idle-detection=()', |
| 152 | + 'magnetometer=()', |
| 153 | + 'microphone=()', |
| 154 | + 'midi=()', |
| 155 | + 'payment=()', |
| 156 | + 'picture-in-picture=()', |
| 157 | + 'publickey-credentials-get=()', |
| 158 | + 'screen-wake-lock=()', |
| 159 | + 'serial=()', |
| 160 | + 'speaker-selection=()', |
| 161 | + 'usb=()', |
| 162 | + 'web-share=()', |
| 163 | + 'xr-spatial-tracking=()', |
| 164 | + ], |
| 165 | + 'Referrer-Policy': ['strict-origin-when-cross-origin'], |
| 166 | + 'Strict-Transport-Security': [ |
| 167 | + 'max-age=63072000', |
| 168 | + 'includeSubDomains', |
| 169 | + 'preload', |
| 170 | + ], |
| 171 | + 'X-Content-Type-Options': ['nosniff'], |
| 172 | + 'X-Frame-Options': ['DENY'], |
| 173 | + 'X-XSS-Protection': ['1', 'mode=block'], |
| 174 | + }, |
| 175 | + }, |
| 176 | + ], |
| 177 | +}; |
| 178 | + |
| 179 | +export default config; |
0 commit comments