Repository navigation
fix(pages): a prefix that is not a language 404s instead of serving a second address - #315
Merged
Merged
Conversation
…ddress `/zz/meditations/105`, its `/embed`, the lecture pair and `/zz/map` all answered 200 with the page at the bare path, and the full pages declared that prefixed URL their own canonical. The meditation, lecture and map matchers each accepted an optional `/xx` or `/xx-YY` segment ahead of their path. That segment never carries a real locale by the time a route runs: `+onBeforeRoute` strips one SahajCloud defines into `urlLogical`, and Vike hands every route function that path, on the server and in the client router. So only a code SahajCloud does not define (`zz`, `st`) ever reached the optional group, and the tolerance did nothing but mint duplicates. The matchers now take the bare path, and an unknown prefix 404s through the error page like `/zz/about` already did. `pages/[slug]/+route.ts:33` is left as it is: its locale-shaped regex refuses a path rather than tolerating one, so it creates no duplicate, and #288 pins `/zz/` against it. The routing spec in `pages/onBeforeRoute.test.ts` runs the hook and then every `+route.ts` under `pages/` (an `import.meta.glob`, so a new route joins it), and pins both sides: a real locale still reaches the meditation, lecture and map routes, and nothing claims the `/zz/` paths. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjZcE8bs5uRJ6dsg6kw
The unit specs prove the matchers; these prove the deployed Worker, where the duplicates were first seen. A meditation and its embed under `/zz/` must 404, and so must `/zz/map` and a route under it, beside a `/map` control that keeps a preview serving no map at all from passing them. Both specs fail against the current main Worker (200 for each `/zz/` path) and pass once this branch's preview serves the fixed matchers. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjZcE8bs5uRJ6dsg6kw
The composition spec listed only document paths, so an index route that kept the old optional prefix (as the open /meditations index does) would answer /zz/meditations and stay green. The route doc lines now say a real locale is stripped before the matcher runs, which is what the matcher's own comment states. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjZcE8bs5uRJ6dsg6kw
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
wemeditate-design | 3a25d61 | Commit Preview URL Branch Preview URL |
Nov 19 2026, 11:07 PM |
Ardnived
approved these changes
Nov 20, 2026
sydevs-bot
pushed a commit
that referenced
this pull request
Nov 20, 2026
#315 landed on `main` and removed the optional locale prefix from every document-route matcher: `+onBeforeRoute` strips a real locale into `urlLogical` before any route runs, so a prefix still reaching a matcher is not a locale, and tolerating it served `/zz/meditations/105` as a second address of the page. This branch's new `/meditations` matcher was built on the prefix that fix deletes, so `main`'s rule is applied to it too rather than only to the hunk git flagged: - `documentRoutePattern` takes `main`'s bare-path regex. - `MEDITATIONS_INDEX_ROUTE` loses the prefix, and `LOCALE_PREFIX` goes with it — nothing else referenced it. - `pages/meditations/(index)/route.test.ts` pinned `/fr/meditations` and `/pt-BR/meditations` as matches. They are now refused, beside `/zz/`. - `pages/onBeforeRoute.test.ts` gains the positive counterpart of the `/zz/meditations` row it already carried: `/fr/meditations` reaches the new index route through the hook. The list route itself is unchanged — `/fr/meditations` still answers 200, because the hook hands the router `/meditations`. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjVZyqL7JbDkVBd4Szb
This was referenced Nov 20, 2026
sydevs-bot
pushed a commit
that referenced
this pull request
Nov 20, 2026
Smoke (web) failed on `/zz/map` and `/zz/meditations/142` answering 200 where 404 is asserted. Neither assertion exists on this branch: both arrived with #315 on main. CI checks out the pull request's merge ref, so it ran main's new smoke specs, while the Cloudflare preview it fetched was built from this branch's tip, which predates that routing fix. Production answers 404 for `/zz/map`; all three of this branch's previews answer 200. So the merge is the fix. Pushing it rebuilds the preview with #315's routes in it, and the specs then run against a Worker that has them. Nothing conflicted. #315 touched `lib/atlas-route.ts`, `lib/document-routes.ts` and the four `+route.ts` matchers; this branch touches the meditations region of `server/sahajcloud-client.ts` and the `_meditation.ts` loader, which runs only after a matcher has claimed the path. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjXbkobB5uhfhfthYE5
sydevs-bot
pushed a commit
that referenced
this pull request
Nov 20, 2026
#315 made the document route matchers take a bare path: Vike hands a route function the path `+onBeforeRoute` already stripped, so a prefix that still reaches one is not a language, and tolerating it served `/zz/lectures/163` as a second address. `/oembed` is a Hono route, where nothing stripped anything, so it was relying on that tolerance to resolve `/fr/lectures/163`. It now strips the locale itself through `localeFromPath` — the same derivation the rest of the site uses, which leaves an undefined code in place, so a media path under one is refused here too. The locale rides on the resolved target instead of being parsed a second time in the handler, so the path the matcher saw and the language the player answers in cannot disagree. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjY1HQUVjZbWcpFW73g
sydevs-bot
pushed a commit
that referenced
this pull request
Nov 20, 2026
The lane reached `/oembed` only through the discovery link on a bare `/lectures/:id`, so no spec sent it a prefixed URL at all — which is why the merge with #315 broke the locale case with the smoke lane green. The refusal is the half with no data dependency: a lecture need not be published in any particular language for `/zz/` to 404. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjY1HQUVjZbWcpFW73g
sydevs-bot
pushed a commit
that referenced
this pull request
Nov 20, 2026
Fixes the red `Smoke (web)`: `/zz/map should 404: expected 200 to be 404`, and the same for `/zz/meditations/<id>`. The smoke job runs the spec from the merge ref but fetches the preview Cloudflare built from this branch's head (#295). `main` carries both halves of #315 — the matchers that stop an unknown prefix minting a second address, and the smoke spec that pins it — while this head carried only the spec's absence. Bringing the base in puts the matchers on the head the preview is built from, so there is nothing else to fix here. Base merged clean. Lean gate green: lint, `tsc --noEmit`, 1482 tests in 150 files, `pages/onBeforeRoute.test.ts` among them. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjXMjw8p5ZyKppLjncT
This was referenced Nov 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Before this change, a made-up language prefix still opened the page:
/zz/meditations/105,/zz/lectures/162, their/embedplayers,/zz/mapand/zz/map/nlall returned 200. That gave every meditation, lecture and the map an unlimited number of duplicate addresses. These paths now return 404 and render the existing "Content Not Found" page. Real language prefixes behave as before:/fr/meditations/105/embed,/ru/lectures/162/embedand/de/mapstill work, and so do the unprefixed English addresses.What changed and why
lib/document-routes.tsmatchDocumentRoutenow matches^/${collection}/([^/]+)${suffix}/?$. The optional(?:/[a-z]{2}(?:-[A-Z]{2})?)?group is gone.pages/+onBeforeRoute.tsalready strips a real locale and setsurlLogical, and Vike builds the route functions'urlPathnamefrom that value on both server and client (vike/dist/shared-server-client/getPageContextUrlComputed.js;onBeforeRouteruns with env{server, client}). So the only prefixes that ever reached that group were codes SahajCloud does not define. A⚠comment on the matcher records this constraint. Measured on localvike dev, before → after:/zz/meditations/105200→404, its embed 200→404,/zz/lectures/162200→404, its embed 200→404. Deployed main Worker today:/zz/meditations/105and its embed return 200. Pinned bylib/document-routes.test.ts("does not match a path under an unknown code / a locale-shaped code / a compound code", "does not match an embed path under a prefix").lib/atlas-route.tsmatchMapRoutenow uses/^\/map(\/.*)?$/./zz/mapand/zz/map/nlgo from 200 to 404./mapand/map/nlstay 200. Pinned bylib/atlas-route.test.ts, which moves/zz/map,/zz/map/nl/amsterdamand/fr/map(as the router would see it, unstripped) to the does-not-match table.pages/onBeforeRoute.test.ts"onBeforeRoute with the route functions" runs the real hook, then everypages/**/+route.tsfound throughimport.meta.glob. A real locale must reach exactly one route:/fr/meditations/105,/fr/meditations/105/embed,/pt-BR/lectures/162,/ru/lectures/162/embed,/de/map,/de/map/nl/amsterdam. No route may claim/zz/meditations,/zz/meditations/105, its embed,/zz/lectures,/zz/lectures/162, its embed,/zz/map,/zz/map/nl/amsterdamor/zz/about. Because the glob picks up new routes, a future index route that keeps the old tolerant prefix fails this spec. I checked that by adding a temporarypages/meditations/(index)/+route.tswith the tolerant/meditationsindex pattern from feat(components): a MeditationLibrary for the meditations index block #293: "routes nothing for /zz/meditations" failed. With the source fix reverted, the 13 new unit assertions fail.tests/smoke/web/meditations.smoke.test.tsadds "serves neither page under a prefix that is not a locale" (/zz/meditations/<id>and its embed must return 404). The newtests/smoke/web/map.smoke.test.tsfirst checks that/mapreturns 200 as a control, so its 404s cannot pass on a preview that has no map, then asserts/zz/mapand/zz/map/nlreturn 404. Run against today's main Worker, both specs fail (2 of 3 tests).pages/{meditations,lectures}/[id]/{(full),embed}/+route.tscomments no longer say "an optional /:locale prefix". They now say+onBeforeRoutestrips a real locale before the route runs, which matches the matcher's own comment.pages/[slug]/+route.ts:33is left as it is. That regex does not tolerate a prefix. It is a guard that refuses a path whose first segment looks like a locale, so it creates no duplicate address./zz/aboutalready returns 404 on the deployed main Worker and locally, and feat(server): switch wemeditate.com over to the new site #288 pins this guard (match('/zz/')is false). The composition spec still asserts that/zz/aboutreaches no route./fr/meditations/105/embedand/fr/lectures/162/embedstill return 200, and the composition spec pins them.Not in this PR
ContentHead(lib/head.tsx,localeUrl(origin, locale, path)) emits a prefixed self-canonical. I tested this locally with the locale gate bypassed temporarily (the change was reverted and never committed):/fr/meditations/105gave a canonical of…/fr/meditations/105, and/fr/lectures/162gave…/fr/lectures/162. The decision wants the English (unprefixed) address. feat(seo): share metadata and JSON-LD at parity with the old site #282 rewrites this code, and itslib/content-seo.tscanonicalUrl(route)is stilllocaleUrl(route.origin, route.locale, route.path). That value also feeds og:url, the JSON-LDurlfields and the oEmbed discoveryurl=. Follow-up once feat(seo): share metadata and JSON-LD at parity with the old site #282 merges: build those four values fromlocaleUrl(origin, DEFAULT_LOCALE, path)inmeditationSeoandlectureSeo, and keep the visitor's locale forog:localeandinLanguage. Production offers only English today (availableLocalesis[]), so/fr/meditations/105returns 404 for now.VideoPlayerwraps itself inI18nProviderandSubtitlePreferenceselects the page-language track, so lectures follow the URL language. Before feat(player): move VideoPlayer from Vidstack to Video.js 10 #285, Chromium against the deployed Worker showed the IT track on/it/lectures/162/embedand the RU track on/ru/lectures/162/embed. One gap remains:PageTemplate's featured video never passessubtitleLang, so its inline track is always labelled EN. Passing the page locale would mislabel the cases where English is served as the fallback. A correct fix needs the cues' source locale (for example, a read withfallbackLocaleoff). Affected today: 5 live pages have a featured video, and 1 of the 6 videos has subtitles.pnpm buildwas not run. This bundle changes no dependencies, CSS, bundling or CI config.Reconciled with open PRs
matchDocumentRoute,resolveOEmbedTargetinserver/oembed/index.ts. It passes the consumer's rawurl=pathname, so it relies on the matcher accepting a locale prefix. The textual merge is clean, but I merged feat(seo): share metadata and JSON-LD at parity with the old site #282 into this branch and ran its tests: 2 fail (server/oembed/index.test.ts > resolves a locale-prefixed media URLandserver/oembed/routes.test.ts > reads the player in the locale the consumer's URL named). Locale-prefixed oEmbed would then return 404. Fix for whichever of the two merges second: inresolveOEmbedTarget, matchlocaleFromPath(parsed.pathname).pathWithoutLocale(fromlib/urls.ts) instead ofparsed.pathname. This strips a real locale the same way the router does, and/zz/lectures/163is still refused. KeeplocaleOf(url)reading the prefix for the player language, and add a/zz/...refuse case to its table. I applied this one-line change on the merged probe: server/oembed passed 28/28. I expect this PR to merge first, so feat(seo): share metadata and JSON-LD at parity with the old site #282's rebase carries the fix. If feat(seo): share metadata and JSON-LD at parity with the old site #282 lands first, this PR takes the fix before it merges.lib/document-routes.tsat the pattern lines. feat(components): a MeditationLibrary for the meditations index block #293 factors the old optional group intoLOCALE_PREFIXand reuses it forMEDITATIONS_INDEX_ROUTE, which would bring the duplicate back as/zz/meditations. To resolve on rebase: dropLOCALE_PREFIX, make the index route^/meditations/?$, and inpages/meditations/(index)/route.test.tsreplace the/fr/meditationsand/pt-BR/meditationsmatch cases with a/zz/meditationsdoes-not-match case. If the tolerant pattern survives the rebase, this PR's composition spec fails on it.pages/[slug]/+route.tsis untouched here, so feat(server): switch wemeditate.com over to the new site #288's/zz/guard test still holds.localeFromPathand its{ locale, prefixed }result are unchanged..claude/is edited.Test results
.claude/skills/pr-prep/check.shexit 0 after the rebase onto main:tsc --noEmit: passed.pnpm build: not run (not required for this bundle).🤖 Generated with Claude Code
https://claude.ai/code/session_01Mg9rjZcE8bs5uRJ6dsg6kw