From 23e6fa3c8aa55c3cede64b76d381c4da75017517 Mon Sep 17 00:00:00 2001 From: kamijo-haruto Date: Fri, 31 Jul 2026 11:01:22 +0900 Subject: [PATCH] =?UTF-8?q?[feat]=20QR=E3=82=B3=E3=83=BC=E3=83=89=E3=81=AB?= =?UTF-8?q?=E7=84=BC=E3=81=8D=E8=BE=BC=E3=82=80=E3=83=89=E3=83=A1=E3=82=A4?= =?UTF-8?q?=E3=83=B3=E3=82=92=20t.nutfes.net=20=E3=81=AB=E5=88=87=E3=82=8A?= =?UTF-8?q?=E6=9B=BF=E3=81=88=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 印刷されるURLの大半はドメインだった。workers.dev のサブドメインは50文字で、 短縮コード(29文字削減)より支配的な要素になっていた。t.nutfes.net は20文字で、 シンボルが 49×49 から 37×37 モジュールに下がる。今回の一連の変更で最大の効果。 QR用のドメインだけを切り替え、管理APIは workers.dev のままにした。APIのURLの 長さは何のコストにもならず、据え置けば ALLOWED_ORIGINS もログインセッションも 触らずに済む。VITE_FWD_BASE_URL はもともとこの用途のために分けてあった。 ルートは wrangler.jsonc では宣言しない。ダッシュボードのCustom Domainとして 登録済みで、両方に書くとデプロイがダッシュボードと衝突する。どこで管理されて いるかが分からなくなるのが一番困るので、その旨をコメントに残した。 workers.dev のサブドメインは無効化しないこと。カスタムドメイン以前に印刷した QRコードはそちらを指しており、紙は刷り直せない。両方のホスト名が解決し続ける 必要がある。実測で両方とも302を返すことを確認済み。 Co-Authored-By: Claude Opus 5 (1M context) --- packages/api/wrangler.jsonc | 10 ++++++++++ packages/web/.env.example | 11 ++++++++--- packages/web/.env.production | 12 ++++++++++++ 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/packages/api/wrangler.jsonc b/packages/api/wrangler.jsonc index 637594a..2d45db5 100644 --- a/packages/api/wrangler.jsonc +++ b/packages/api/wrangler.jsonc @@ -13,6 +13,16 @@ // Custom domain / route the redirect endpoint should live on. // Leave this out entirely to use the workers.dev subdomain instead. // "routes": [{ "pattern": "links.example.com", "custom_domain": true }], + // + // t.nutfes.net is attached to this Worker as a Custom Domain in the Cloudflare + // dashboard, not here — declaring it in both places is how you get a deploy + // that fights the dashboard. It is the host printed into QR codes; see + // VITE_FWD_BASE_URL in packages/web/.env.production for why (20 characters + // against 50, which is 37x37 modules instead of 49x49). + // + // Do not disable the workers.dev subdomain. QR codes printed before the custom + // domain existed carry it, and both hostnames have to keep resolving for as + // long as that paper is on a wall. // Rate limiter for POST /auth/login. `unsafe` bindings are excluded from // `wrangler types`, so the interface is declared by hand in src/auth/types.ts. // The limiter is per-colo, not global — plenty for an admin panel. diff --git a/packages/web/.env.example b/packages/web/.env.example index 178109f..2755e44 100644 --- a/packages/web/.env.example +++ b/packages/web/.env.example @@ -1,6 +1,11 @@ # Copy to `.env.local` for local development. VITE_API_URL=http://localhost:8789 -# Optional: base URL encoded into generated QR codes, if it should differ -# from VITE_API_URL (e.g. a custom domain in front of the same Worker). -# VITE_FWD_BASE_URL=https://links.example.com +# Optional: base URL encoded into generated QR codes, if it should differ from +# VITE_API_URL (a short custom domain in front of the same Worker). Every +# character here is printed into every QR code, so a short host is worth more +# than any other shortening — production uses https://t.nutfes.net. +# +# Leave it unset locally: QR codes then point at your local Worker, which is what +# makes a scan testable without deploying. +# VITE_FWD_BASE_URL=https://t.example.com diff --git a/packages/web/.env.production b/packages/web/.env.production index 44a11cc..c7e0104 100644 --- a/packages/web/.env.production +++ b/packages/web/.env.production @@ -1 +1,13 @@ VITE_API_URL=https://trackinglink.nutfes-nutmeg9488.workers.dev + +# Domain baked into generated QR codes. Both hostnames reach the same Worker, so +# this only changes what gets printed — https://t.nutfes.net is 20 characters +# against the workers.dev subdomain's 50, which takes the printed symbol from +# 49x49 modules down to 37x37 at the same error-correction level. +# +# The admin API deliberately stays on workers.dev: its URL length costs nothing, +# and leaving it alone means ALLOWED_ORIGINS and the login session are untouched. +# +# workers.dev must stay enabled regardless — QR codes already printed carry that +# hostname, and paper cannot be reissued. +VITE_FWD_BASE_URL=https://t.nutfes.net