@@ -46,14 +46,11 @@ export default function WebsiteData() {
Hosting
- Cloudflare Workers. Runs the site’s code on
- Cloudflare’s network, in the data centre nearest to you,
- delivers its pages and files, including the setup script, and
- protects the site from attacks. Cloudflare receives the details
- it needs to deliver each page: your Internet Protocol (IP)
- address, browser details, the page you asked for and the time.
- It keeps a log of the requests the site’s code handles, and of
- any errors, for up to 7 days.
+ Cloudflare. Serves the site’s prebuilt pages
+ and files, including the setup script. It processes your IP
+ address, browser details, the address you requested and the
+ time of the request to deliver and protect the site. We’ve
+ turned off Cloudflare Workers Logs for this site.
diff --git a/app/robots.txt/route.ts b/app/robots.txt/route.ts
deleted file mode 100644
index d9db2d1..0000000
--- a/app/robots.txt/route.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-import { SITE_ORIGIN } from "../../lib/site";
-export function GET() {
- return new Response(`User-agent: *\nAllow: /\nSitemap: ${SITE_ORIGIN}/sitemap.xml\n`, {
- headers: {
- "Content-Type": "text/plain; charset=utf-8",
- "Cache-Control": "public, max-age=3600",
- },
- });
-}
diff --git a/app/sitemap.xml/route.ts b/app/sitemap.xml/route.ts
deleted file mode 100644
index 2282811..0000000
--- a/app/sitemap.xml/route.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-import content from "../../content/docs.json";
-import { SITE_ORIGIN } from "../../lib/site";
-export function GET() {
- const paths = [
- "/",
- "/docs",
- "/docs/screenshot-evidence",
- "/open",
- ...content.pages.map((page) => `/docs/${page.slug}`),
- ];
- const entries = paths.map((path) => `${SITE_ORIGIN}${path}`).join("");
- return new Response(
- `${entries}`,
- {
- headers: {
- "Content-Type": "application/xml; charset=utf-8",
- "Cache-Control": "public, max-age=3600",
- },
- },
- );
-}
diff --git a/justfile b/justfile
index 04e47ac..5de86ec 100644
--- a/justfile
+++ b/justfile
@@ -15,7 +15,7 @@
set shell := ["bash", "-uc"]
-wrangler_config := "dist/server/wrangler.json"
+built_page := "dist/client/index.html"
local_url := "http://127.0.0.1:4318"
public_url := "https://fxcss.com"
@@ -38,10 +38,10 @@ _installed:
_logged-in: _installed
@npx wrangler whoami 2>&1 | grep -q "not authenticated" && { echo "▸ Not signed in to wrangler — run 'just login' first"; exit 1; } || true
-# wrangler's own error for a missing config is an ENOENT that reads as a broken
-# build rather than a skipped one.
+# Without a build, wrangler complains about the assets directory, which reads
+# as a broken config rather than a skipped build.
_built: _installed
- @test -f {{wrangler_config}} || { echo "▸ {{wrangler_config}} missing — run 'just build' first"; exit 1; }
+ @test -f {{built_page}} || { echo "▸ {{built_page}} missing — run 'just build' first"; exit 1; }
# The Website CI checks before the build: documentation, types, lint, tests,
# the installer, and the dependency audit (scripts/audit.mjs).
@@ -60,18 +60,18 @@ check: _installed
dev: _installed
npm run dev -- --host 127.0.0.1 --port 4317
-[doc("Build the Worker into dist/")]
+[doc("Build every page into dist/client")]
build: _installed
npm run build
- @echo "▸ Built. Config at {{wrangler_config}}"
+ @echo "▸ Built. Pages are in dist/client"
# Install browsers once with `npx playwright install chromium firefox`.
-[doc("Run browser interaction checks against the built Worker")]
+[doc("Run browser interaction checks against the built site")]
browser: _built
npm run test:browser
-# The built Worker under wrangler (workerd), the same runtime as production.
-[doc("Serve the built Worker on http://127.0.0.1:4318")]
+# The built site under wrangler (workerd), the same runtime as production.
+[doc("Serve the built site on http://127.0.0.1:4318")]
preview: _built
npm start -- --ip 127.0.0.1 --port 4318
@@ -89,7 +89,7 @@ verify url=local_url: _installed
# Proves the config, the custom domains and the assets are coherent without
# uploading anything, and needs no login. CI runs it on every change.
-[doc("wrangler deploy --dry-run against the built config")]
+[doc("wrangler deploy --dry-run against the built site")]
dry-run: _built
npm run deploy -- --dry-run
@@ -100,23 +100,18 @@ login: _installed
# Creates the fxcss-website Worker the first time and attaches fxcss.com and
# www.fxcss.com (the deploy script passes both domains). Cloudflare adds their
# DNS records and certificates; do not create them by hand.
-[doc("Upload the built Worker and attach fxcss.com")]
+[doc("Upload the built site and attach fxcss.com")]
deploy: _built _logged-in
npm run deploy
# The whole sequence, in the only order that works.
[doc("First deploy: check → build → dry-run → deploy")]
first-deploy: check build dry-run deploy
- @echo "▸ Deployed. Two zone settings cover static files such as /install.sh, which are served before the Worker runs:"
+ @echo "▸ Deployed. Only two zone settings redirect plain HTTP and www, so both must be on:"
@echo " SSL/TLS → Edge Certificates → Always Use HTTPS"
@echo " Rules → Redirect Rules → 'Redirect from WWW to root'"
@echo "▸ Then: just verify {{public_url}}"
-# Live logs from the deployed Worker. Ctrl-C to stop.
-[doc("Stream the deployed Worker's logs")]
-tail: _built _logged-in
- npx wrangler tail --config {{wrangler_config}} --format pretty
-
# The documentation pages are generated from main's README. This refreshes
# the recorded copy in content/source from a checkout of main; commit the
# result. Website CI warns when that copy is behind main.
diff --git a/next.config.ts b/next.config.ts
index 44845d6..8ff559d 100644
--- a/next.config.ts
+++ b/next.config.ts
@@ -1,5 +1,7 @@
import type { NextConfig } from 'next';
const nextConfig: NextConfig = {
+ // Every page is built to a file, so no site code runs per request.
+ output: 'export',
poweredByHeader: false,
// Documentation metadata comes from local build data. Resolve it before
// sending HTML so every crawler receives titles and canonicals in .
diff --git a/package-lock.json b/package-lock.json
index 5cfc391..2703ee0 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -20,7 +20,6 @@
"vinext": "1.0.1"
},
"devDependencies": {
- "@cloudflare/vite-plugin": "1.63.1",
"@cloudflare/workers-types": "5.20261006.1",
"@playwright/test": "1.64.1",
"@tailwindcss/postcss": "4.2.1",
@@ -585,28 +584,6 @@
}
}
},
- "node_modules/@cloudflare/vite-plugin": {
- "version": "1.63.1",
- "resolved": "https://registry.npmjs.org/@cloudflare/vite-plugin/-/vite-plugin-1.63.1.tgz",
- "integrity": "sha512-6EtAoRqWryl43bYiCl7yvCBHi3R+L/fM11zu8zRyvBMe0Yk63NseyrhA19nO5Y1yrrk6dD+Su7NBZhDuUbjh0g==",
- "dev": true,
- "license": "MIT",
- "dependencies": {
- "@cloudflare/unenv-preset": "2.16.2",
- "miniflare": "5.20261006.1-alpha",
- "unenv": "2.0.0-rc.24",
- "workerd": "1.20261006.1",
- "wrangler": "4.149.0",
- "ws": "8.21.0"
- },
- "bin": {
- "cf-vite": "bin/cf-vite"
- },
- "peerDependencies": {
- "vite": "^6.1.0 || ^7.0.0 || ^8.0.0",
- "wrangler": "^4.149.0"
- }
- },
"node_modules/@cloudflare/workerd-darwin-64": {
"version": "1.20261006.1",
"resolved": "https://registry.npmjs.org/@cloudflare/workerd-darwin-64/-/workerd-darwin-64-1.20261006.1.tgz",
diff --git a/package.json b/package.json
index 24cda68..316f5ab 100644
--- a/package.json
+++ b/package.json
@@ -8,9 +8,9 @@
"scripts": {
"dev": "vinext dev",
"build": "vinext build",
- "start": "wrangler dev --config dist/server/wrangler.json",
- "deploy": "wrangler deploy --config dist/server/wrangler.json --domain fxcss.com --domain www.fxcss.com",
- "lint": "oxlint app components hooks lib scripts tests proxy.ts next.config.ts vite.config.ts playwright.config.ts",
+ "start": "wrangler dev --config wrangler.static.jsonc",
+ "deploy": "wrangler deploy --config wrangler.static.jsonc --domain fxcss.com --domain www.fxcss.com",
+ "lint": "oxlint app components hooks lib scripts tests next.config.ts vite.config.ts playwright.config.ts",
"format": "oxfmt",
"content": "node scripts/build-content.mjs",
"predev": "npm run content",
@@ -35,7 +35,6 @@
"vinext": "1.0.1"
},
"devDependencies": {
- "@cloudflare/vite-plugin": "1.63.1",
"@cloudflare/workers-types": "5.20261006.1",
"@playwright/test": "1.64.1",
"@tailwindcss/postcss": "4.2.1",
@@ -60,9 +59,7 @@
"satori": {
"fflate": "0.7.5"
},
- "miniflare": {
- "undici": "7.30.1"
- },
+ "undici": "7.30.1",
"@ts-morph/common": {
"minimatch": "11.0.3"
}
diff --git a/proxy.ts b/proxy.ts
deleted file mode 100644
index 444c5ff..0000000
--- a/proxy.ts
+++ /dev/null
@@ -1,55 +0,0 @@
-import { NextResponse, type NextRequest } from 'next/server';
-
-// Sent with every production response the Worker makes, redirects included.
-// Static files are served before the Worker runs, so public/_headers gives
-// them the same headers.
-const SECURITY_HEADERS = {
- 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains',
- 'X-Content-Type-Options': 'nosniff',
- 'X-Frame-Options': 'DENY',
- 'Permissions-Policy': 'camera=(), microphone=(), geolocation=()',
- 'Referrer-Policy': 'strict-origin-when-cross-origin',
-};
-
-function withSecurityHeaders(response: NextResponse) {
- for (const [name, value] of Object.entries(SECURITY_HEADERS))
- response.headers.set(name, value);
- return response;
-}
-
-export function proxy(request: NextRequest) {
- const url = new URL(request.url);
- if (
- url.hostname === 'www.fxcss.com' ||
- (url.hostname === 'fxcss.com' && url.protocol === 'http:')
- ) {
- url.hostname = 'fxcss.com';
- url.protocol = 'https:';
- url.port = '';
- return withSecurityHeaders(NextResponse.redirect(url, 308));
- }
- if (process.env.NODE_ENV !== 'production') return NextResponse.next();
- const nonce = crypto.randomUUID().replaceAll('-', '');
- const csp = [
- "default-src 'self'",
- `script-src 'self' 'nonce-${nonce}' 'strict-dynamic' https://scripts.simpleanalyticscdn.com`,
- "style-src 'self' 'unsafe-inline'",
- "img-src 'self' data: https://queue.simpleanalyticscdn.com",
- "font-src 'self'",
- "connect-src 'self' https://queue.simpleanalyticscdn.com",
- "object-src 'none'",
- "base-uri 'self'",
- "form-action 'none'",
- "frame-ancestors 'none'",
- ].join('; ');
- const headers = new Headers(request.headers);
- // Replace any client-supplied policy before the renderer reads its nonce.
- headers.set('Content-Security-Policy', csp);
- const response = withSecurityHeaders(
- NextResponse.next({ request: { headers } }),
- );
- response.headers.set('Content-Security-Policy', csp);
- response.headers.set('Cache-Control', 'private, no-store');
- return response;
-}
-export const config = { matcher: ['/:path*'] };
diff --git a/public/.assetsignore b/public/.assetsignore
index abdba0a..8a661fa 100644
--- a/public/.assetsignore
+++ b/public/.assetsignore
@@ -1,8 +1,8 @@
-# Files wrangler must never upload as static assets. Vite copies public/ into
-# dist/client, and the Cloudflare Vite plugin prepends this file to the
-# dist/client/.assetsignore it writes (gitignore syntax). Never list
+# Files wrangler must never upload as static assets (gitignore syntax). Vite
+# copies this file into dist/client, where wrangler reads it. Never list
# .well-known/ here: security.txt stays public.
.git/
+.vite/
.wrangler/
.DS_Store
.env*
diff --git a/public/_headers b/public/_headers
index 15eae06..5e18485 100644
--- a/public/_headers
+++ b/public/_headers
@@ -1,11 +1,20 @@
-# Static files are served before the Worker runs, so they take their security
-# headers from here; proxy.ts sets the same headers for pages.
+# Every page and file takes its security headers from here. Pages are built
+# ahead of time, so they cannot carry a per-request script nonce, and the
+# framework's page data is delivered as inline scripts. The policy allows inline
+# scripts and still limits where scripts can load from.
/*
Strict-Transport-Security: max-age=31536000; includeSubDomains
X-Content-Type-Options: nosniff
Referrer-Policy: strict-origin-when-cross-origin
Permissions-Policy: camera=(), microphone=(), geolocation=()
X-Frame-Options: DENY
+ Content-Security-Policy: default-src 'self'; script-src 'self' 'unsafe-inline' https://scripts.simpleanalyticscdn.com; style-src 'self' 'unsafe-inline'; img-src 'self' data: https://queue.simpleanalyticscdn.com; font-src 'self'; connect-src 'self' https://queue.simpleanalyticscdn.com; object-src 'none'; base-uri 'self'; form-action 'none'; frame-ancestors 'none'
+
+/robots.txt
+ Cache-Control: public, max-age=3600
+
+/sitemap.xml
+ Cache-Control: public, max-age=3600
/install.sh
Content-Type: text/plain; charset=utf-8
@@ -13,9 +22,10 @@
X-Robots-Tag: noindex
# The catalogue is a static page that fxcss generated. It needs only its own
-# inline script and styles and its own images.
+# inline script and styles and its own images, so it replaces the policy above.
/catalogue/*
Cache-Control: public, max-age=3600
+ ! Content-Security-Policy
Content-Security-Policy: default-src 'none'; img-src 'self'; style-src 'unsafe-inline'; script-src 'unsafe-inline'; base-uri 'none'; form-action 'none'; frame-ancestors 'none'
# These filenames change whenever their content changes.
@@ -35,10 +45,8 @@
/evidence/*
Cache-Control: public, max-age=3600
-# Uptime probe: Blackbox fetches /ratchet every minute. A static file is
-# answered before the Worker runs, so the probe costs no CPU (a homepage probe
-# renders the page each time). Typed and uncached here so every probe reaches
-# the asset store, not an edge cache.
+# Uptime probe: Blackbox fetches /ratchet every minute. Typed and uncached here
+# so every probe reaches the asset store, not an edge cache.
/ratchet
Content-Type: text/plain; charset=utf-8
Cache-Control: no-cache, max-age=0, must-revalidate
diff --git a/public/_redirects b/public/_redirects
new file mode 100644
index 0000000..e8c8ac9
--- /dev/null
+++ b/public/_redirects
@@ -0,0 +1,4 @@
+/field-guide /docs 308
+/showcase / 308
+/workbench / 308
+/editorial / 308
diff --git a/public/robots.txt b/public/robots.txt
new file mode 100644
index 0000000..ed44318
--- /dev/null
+++ b/public/robots.txt
@@ -0,0 +1,3 @@
+User-agent: *
+Allow: /
+Sitemap: https://fxcss.com/sitemap.xml
diff --git a/scripts/build-content.mjs b/scripts/build-content.mjs
index dac8887..2a91dce 100644
--- a/scripts/build-content.mjs
+++ b/scripts/build-content.mjs
@@ -256,7 +256,19 @@ await fs.writeFile(
path.join(site, 'content/docs.json'),
JSON.stringify(output, null, 2) + '\n',
);
-// A content-hashed asset can be cached independently of the nonce-bearing HTML.
+// The site is static files, so the sitemap is one too. It follows the pages.
+const sitemapEntries = [
+ '/',
+ '/docs',
+ '/docs/screenshot-evidence',
+ '/open',
+ ...docs.map((page) => `/docs/${page.slug}`),
+].map((route) => `https://fxcss.com${route}`);
+await fs.writeFile(
+ path.join(site, 'public/sitemap.xml'),
+ `${sitemapEntries.join('')}\n`,
+);
+// A content-hashed asset can be cached for a year, unlike the HTML.
const searchIndex = JSON.stringify(docs.map(({ slug, title, description, chapter, group, search }) =>
({ slug, title, description, chapter, group, search }),
));
diff --git a/scripts/check-built-site.sh b/scripts/check-built-site.sh
index 67692d9..f91d806 100755
--- a/scripts/check-built-site.sh
+++ b/scripts/check-built-site.sh
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
-# Serves the built Worker under wrangler (workerd, the production runtime) and
+# Serves the built site under wrangler (workerd, the production runtime) and
# runs the production checks against it. Website CI and the Refresh docs
# workflow both run this after `npm run build`; locally, `just preview` and
# `just verify` do the same in two terminals.
diff --git a/scripts/check-site.mjs b/scripts/check-site.mjs
index 5418fec..0a125af 100644
--- a/scripts/check-site.mjs
+++ b/scripts/check-site.mjs
@@ -1,6 +1,8 @@
import assert from 'node:assert/strict';
import fs from 'node:fs/promises';
const base = process.argv[2] || 'http://127.0.0.1:4318';
+// The live domain has firewall rules that a local server does not.
+const behindFirewall = new URL(base).hostname === 'fxcss.com';
const data = JSON.parse(
await fs.readFile(new URL('../content/docs.json', import.meta.url)),
);
@@ -140,20 +142,22 @@ for (const route of routes) {
csp.includes('https://queue.simpleanalyticscdn.com'),
`${route}: analytics collection allowed by CSP`,
);
- const nonce = csp.match(/'nonce-([^']+)'/)?.[1];
- assert.ok(nonce, `${route}: script nonce`);
+ assert.ok(
+ csp.includes("script-src 'self' 'unsafe-inline' https://scripts.simpleanalyticscdn.com;"),
+ `${route}: scripts limited to this site and analytics`,
+ );
assert.match(
html,
/