Skip to content

build: serve the site from a Cloudflare Worker - #2

Open
CameronBrooks11 wants to merge 3 commits into
masterfrom
feat/cloudflare-workers-hosting
Open

CameronBrooks11 wants to merge 3 commits into
masterfrom
feat/cloudflare-workers-hosting

Conversation

@CameronBrooks11

Copy link
Copy Markdown
Member

Moves hosting to an assets-only Cloudflare Worker and fixes the contact form.

Contact form

The form posted to mailto: with no name on any field and no script handling submit, so "Send message" opened a blank email. It's gone; the page links the address directly. dist/contact.html is the only page that changes (26 lines removed).

Hosting

  • wrangler.jsonc: an assets-only Worker serving the committed dist/. No Worker script, no build on Cloudflare's side.
  • src/_headers, copied to dist/_headers by scripts/render-assets.js: HSTS, X-Frame-Options, X-Content-Type-Options, Referrer-Policy, Permissions-Policy. The CSP is Content-Security-Policy-Report-Only until each page shows a clean console.
  • CI fails if dist/_headers is missing. Removing the copy line and rebuilding made the check print MISSING: dist/_headers and exit 1; restoring it passes.
  • README: the deployment section describes Workers Builds instead of the manual git pull on the VPS. The pull is why the favicon commit 1a4fe2a never reached the live site (/assets/favicon.svg returns 404 there).

Locally: npm ci, the Prettier check and npm run build all pass, and the rebuilt dist/ matches what's committed.

Before merging

  1. Connect this repo in Cloudflare Workers Builds (production branch master).
  2. Check the *.workers.dev preview: all 7 pages, /assets/favicon.svg, the headers, and what /about.html vs /about return.
  3. Attach integrumsys.com and www.integrumsys.com as custom domains.

None of the form's fields had a name attribute and no script handled
submit, so "Send message" opened a blank mailto: with nothing the
visitor typed. The page now points straight at the address.
The site is static, so an assets-only Worker serves the committed dist/
and Workers Builds deploys on push to master. That replaces the manual
git pull on the VPS, which left the favicon commit undeployed.

src/_headers adds HSTS, framing, referrer and permissions headers; the
CSP ships report-only until every page shows a clean console. CI now
fails if the build stops copying _headers into dist/.
Measured with wrangler dev against the committed dist/.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant