diff --git a/packages/core/package.json b/packages/core/package.json index fbbf92c..99e9b46 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -43,7 +43,7 @@ "url": "https://github.com/cazala/party.git", "directory": "packages/core" }, - "homepage": "https://github.com/cazala/party#readme", + "homepage": "https://caza.la/party/", "bugs": { "url": "https://github.com/cazala/party/issues" }, @@ -64,4 +64,4 @@ "engines": { "node": ">=16.0.0" } -} \ No newline at end of file +} diff --git a/packages/playground/index.html b/packages/playground/index.html index 420bfd4..2fdb1a0 100644 --- a/packages/playground/index.html +++ b/packages/playground/index.html @@ -4,38 +4,39 @@ - Party - Particle system and physics engine + Party — WebGPU particle system and physics engine - + - + - + + - + - +
- \ No newline at end of file + diff --git a/packages/playground/public/_headers b/packages/playground/public/_headers new file mode 100644 index 0000000..3412afa --- /dev/null +++ b/packages/playground/public/_headers @@ -0,0 +1,2 @@ +/* + X-Robots-Tag: noindex diff --git a/packages/playground/public/app-sitemap.xml b/packages/playground/public/app-sitemap.xml new file mode 100644 index 0000000..3e940fc --- /dev/null +++ b/packages/playground/public/app-sitemap.xml @@ -0,0 +1,6 @@ + + + + https://caza.la/party/ + + diff --git a/packages/playground/public/sitemap.xml b/packages/playground/public/sitemap.xml new file mode 100644 index 0000000..f50f82c --- /dev/null +++ b/packages/playground/public/sitemap.xml @@ -0,0 +1,9 @@ + + + + https://caza.la/party/app-sitemap.xml + + + https://caza.la/party/docs/sitemap.xml + + diff --git a/packages/worker/README.md b/packages/worker/README.md index bd76f0e..8ac63ae 100644 --- a/packages/worker/README.md +++ b/packages/worker/README.md @@ -1,22 +1,25 @@ ### `worker` (Cloudflare Worker) -This package deploys a **route-scoped Cloudflare Worker** that serves the Party playground at: +This package deploys a **route-scoped Cloudflare Worker** that serves Party at its canonical URL: -- **`https://caza.la/party`** +- **`https://caza.la/party/`** -It does this by **reverse-proxying** to the upstream origin: +It reverse-proxies canonical requests to the Cloudflare Pages origin: -- **`https://party.caza.la`** +- **`https://party-playground.pages.dev`** -The browser URL stays on **`caza.la/party...`** (no redirects to `*.pages.dev`, `party.caza.la`, or the upstream domain). +The browser URL stays on **`caza.la/party...`**. Requests to the old public origin, **`https://party.caza.la/*`**, receive a permanent redirect to the equivalent canonical path. Existing `/party/...` paths are preserved, so shared playground sessions are not broken. + +The Pages build sends `X-Robots-Tag: noindex` to prevent the raw origin from competing in search results. The Worker removes that header from responses served through the canonical URL. ### Configuration Configured in `wrangler.toml`: - **Worker name**: `cazala-party-worker` -- **Route**: `caza.la/party*` -- **Upstream**: `vars.UPSTREAM_ORIGIN` (default: `https://party.caza.la`) +- **Canonical route**: `caza.la/party*` +- **Redirect route**: `party.caza.la/*` +- **Upstream**: `vars.UPSTREAM_ORIGIN` (default: `https://party-playground.pages.dev`) - **Response header**: `x-edge-proxy: cazala-party-worker` ### Scripts @@ -32,4 +35,3 @@ pnpm --filter worker run typecheck ```bash pnpm --filter worker run deploy ``` - diff --git a/packages/worker/src/index.ts b/packages/worker/src/index.ts index 0952e4f..8ed47ac 100644 --- a/packages/worker/src/index.ts +++ b/packages/worker/src/index.ts @@ -6,6 +6,26 @@ export interface Env { const EDGE_PROXY_HEADER_VALUE = "cazala-party-worker"; const PARTY_PREFIX = "/party"; +const CANONICAL_ORIGIN = "https://caza.la"; +const ALTERNATE_HOST = "party.caza.la"; + +function canonicalPartyPath(pathname: string): string { + if (pathname === PARTY_PREFIX || pathname === "/") { + return `${PARTY_PREFIX}/`; + } + + if (pathname.startsWith(`${PARTY_PREFIX}/`)) { + return pathname; + } + + return `${PARTY_PREFIX}${pathname}`; +} + +function canonicalPartyUrl(url: URL): URL { + const canonicalUrl = new URL(canonicalPartyPath(url.pathname), CANONICAL_ORIGIN); + canonicalUrl.search = url.search; + return canonicalUrl; +} function isBodyAllowed(method: string): boolean { // Cloudflare's fetch follows standard semantics: GET/HEAD should not include a body. @@ -45,6 +65,17 @@ export default { const url = new URL(request.url); // 1) Routing rules + if (url.hostname === ALTERNATE_HOST) { + return new Response(null, { + status: 301, + headers: withEdgeHeader( + new Headers({ + Location: canonicalPartyUrl(url).toString(), + }), + ), + }); + } + if (url.pathname === PARTY_PREFIX) { // Trailing slash normalization (same-host, same-scheme). return new Response(null, { @@ -109,6 +140,8 @@ export default { // 3) Caching (keep it simple) // Only add long-lived caching if upstream didn't provide it. const responseHeaders = withEdgeHeader(upstreamResponse.headers); + // The Pages origin is deliberately noindex. Only the canonical proxy is indexable. + responseHeaders.delete("x-robots-tag"); if (looksLikeAssetPath(upstreamPath) && !responseHeaders.has("cache-control")) { responseHeaders.set("Cache-Control", "public, max-age=31536000, immutable"); } @@ -120,4 +153,3 @@ export default { }); }, }; - diff --git a/packages/worker/wrangler.toml b/packages/worker/wrangler.toml index 60d42ce..e174706 100644 --- a/packages/worker/wrangler.toml +++ b/packages/worker/wrangler.toml @@ -3,9 +3,9 @@ main = "src/index.ts" compatibility_date = "2025-12-30" routes = [ - { pattern = "caza.la/party*", zone_name = "caza.la" } + { pattern = "caza.la/party*", zone_name = "caza.la" }, + { pattern = "party.caza.la/*", zone_name = "caza.la" } ] [vars] -UPSTREAM_ORIGIN = "https://party.caza.la" - +UPSTREAM_ORIGIN = "https://party-playground.pages.dev"