Skip to content

Commit a5fd0b8

Browse files
committed
deploy: enforce HTTPS on hayatepy.dev
1 parent 95d6905 commit a5fd0b8

6 files changed

Lines changed: 68 additions & 1 deletion

File tree

.github/workflows/documentation.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,14 @@ jobs:
9898
apiToken: ${{ env.CLOUDFLARE_API_TOKEN }}
9999
accountId: ${{ vars.CLOUDFLARE_ACCOUNT_ID }}
100100
wranglerVersion: "4.114.0"
101+
- id: deploy-http-redirect
102+
if: env.CLOUDFLARE_API_TOKEN != ''
103+
uses: cloudflare/wrangler-action@ebbaa1584979971c8614a24965b4405ff95890e0 # v4.0.0
104+
with:
105+
apiToken: ${{ env.CLOUDFLARE_API_TOKEN }}
106+
accountId: ${{ vars.CLOUDFLARE_ACCOUNT_ID }}
107+
command: deploy --config wrangler.redirect.jsonc
108+
wranglerVersion: "4.114.0"
101109
- if: env.CLOUDFLARE_API_TOKEN == ''
102110
run: >-
103111
echo "::warning::Cloudflare deploy skipped because

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ Deploy with the account authenticated by Wrangler:
3939
npm run deploy
4040
```
4141

42+
The deploy publishes the static site on the `hayatepy.dev` Custom Domain and a
43+
separate HTTP-only Route that redirects requests to HTTPS. Keeping the redirect
44+
Worker separate means HTTPS asset requests continue to use the static site
45+
Worker directly.
46+
4247
The central site owns cross-package onboarding, runtime selection, ecosystem
4348
navigation, and evidence interpretation. Package-specific API details remain
4449
next to their implementation repositories.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
"description": "Unified documentation for the Hayate Python ecosystem",
66
"scripts": {
77
"build": "uv run zensical build --clean --strict && uv run python scripts/write_headers.py site && uv run python scripts/check_site.py site",
8-
"deploy": "npm run build && wrangler deploy",
8+
"deploy": "npm run build && npm run deploy:site && npm run deploy:redirect",
9+
"deploy:site": "wrangler deploy",
10+
"deploy:redirect": "wrangler deploy --config wrangler.redirect.jsonc",
911
"preview": "npm run build && wrangler dev"
1012
},
1113
"devDependencies": {

tests/test_cloudflare_config.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from __future__ import annotations
2+
3+
import json
4+
from pathlib import Path
5+
6+
ROOT = Path(__file__).parents[1]
7+
8+
9+
def load_config(name: str) -> dict:
10+
return json.loads((ROOT / name).read_text(encoding="utf-8"))
11+
12+
13+
def test_site_uses_canonical_custom_domain() -> None:
14+
config = load_config("wrangler.jsonc")
15+
16+
assert config["name"] == "hayate-docs"
17+
assert config["routes"] == [
18+
{"pattern": "hayatepy.dev", "custom_domain": True},
19+
]
20+
assert config["assets"]["directory"] == "./site"
21+
22+
23+
def test_http_redirect_only_intercepts_plaintext_requests() -> None:
24+
config = load_config("wrangler.redirect.jsonc")
25+
26+
assert config["name"] != "hayate-docs"
27+
assert config["workers_dev"] is False
28+
assert config["routes"] == [
29+
{"pattern": "http://hayatepy.dev/*", "zone_name": "hayatepy.dev"},
30+
]
31+
assert (ROOT / config["main"]).is_file()

workers/http-redirect.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export default {
2+
fetch(request) {
3+
const url = new URL(request.url);
4+
url.protocol = "https:";
5+
return Response.redirect(url, 301);
6+
},
7+
};

wrangler.redirect.jsonc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"$schema": "./node_modules/wrangler/config-schema.json",
3+
"name": "hayate-docs-http-redirect",
4+
"main": "workers/http-redirect.js",
5+
"compatibility_date": "2026-07-28",
6+
"preview_urls": false,
7+
"workers_dev": false,
8+
"routes": [
9+
{
10+
"pattern": "http://hayatepy.dev/*",
11+
"zone_name": "hayatepy.dev"
12+
}
13+
]
14+
}

0 commit comments

Comments
 (0)