Skip to content

Commit 3880b1c

Browse files
committed
Security headers CV vanity URL
1 parent 3c0cd64 commit 3880b1c

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

.github/workflows/cloudflare-worker.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
NETLIFY_JWS_SECRET
3636
steps:
3737
- uses: actions/checkout@v6
38-
- name: Deploy Cloudflare Worker (${{ matrix.worker }})
38+
- name: [${{ matrix.worker }}] Deploy Cloudflare Worker
3939
uses: cloudflare/wrangler-action@v3
4040
with:
4141
apiToken: ${{ secrets.CF_API_TOKEN }}

_cf/security-headers/index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,12 @@ async function handleRequest(req) {
115115
return addSecurity(req, requestUrl)
116116
}
117117

118+
if (match = requestUrl.hostname.match(/^cv-(staging|role)-([^.]+)\./)) {
119+
const type = (match[1] == 'staging' ? 'deploy-preview' : 'role')
120+
requestUrl.hostname = `${type}-${match[2]}--cmbuckley-cv.netlify.app`
121+
return addSecurity(req, requestUrl)
122+
}
123+
118124
if (req.method == 'POST' && requestUrl.hostname == 'cmbuckley.co.uk') {
119125
requestUrl.hostname = 'cmbuckley.netlify.app'
120126
return addSecurity(req, requestUrl)
@@ -126,7 +132,7 @@ async function handleRequest(req) {
126132
return Response.redirect(dest, 302)
127133
}
128134

129-
if (requestUrl.hostname.match(/scripts\.cmbuckley\.co\.uk$/)) {
135+
if (requestUrl.hostname.endsWith('scripts.cmbuckley.co.uk')) {
130136
return await fetch(req)
131137
}
132138

0 commit comments

Comments
 (0)