Skip to content

Answer the bare /osa mount path with a 308 - #501

Merged
neuromechanist merged 3 commits into
developfrom
fix/issue-500-bare-mount-path
Sep 24, 2026
Merged

neuromechanist merged 3 commits into
developfrom
fix/issue-500-bare-mount-path

Conversation

@neuromechanist

@neuromechanist neuromechanist commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

Closes #500.

widget.osc.earth/osa/ works and widget.osc.earth/osa answered 522: the Worker's zone route widget.osc.earth/osa/* does not match the bare path, so the request fell through to the placeholder AAAA 100:: origin. api.osc.earth/osa answered 404 for the same reason in Apache (ProxyPass /osa/).

Changes

  • workers/osa-worker/wrangler.toml: each mounted host (widget.osc.earth, develop-widget.osc.earth) also routes /osa*. The trailing wildcard is required: Cloudflare matches a route against the whole URL including its query string, and a pattern without a trailing * never matches a URL that has one, so an exact /osa route would still leave /osa?x=1 at 522. When patterns overlap the most specific wins, so a later widget.osc.earth/osafoo/* route would still take its own paths.
  • workers/osa-worker/index.js: on a mounted host, a request for exactly /osa answers 308 with Location: /osa/ and the query string kept (308 rather than 301, so a POST keeps its method and body). A path the /osa* route also delivers but that is outside the mount, such as /osafoo/chat, answers 404 rather than being read as community osafoo.
  • deploy/apache-api.osc.earth.conf: RedirectMatch 308 ^/osa$ /osa/ and ^/osa-dev$ /osa-dev/. RedirectMatch matches the path only and carries the query string over. The server's copy is applied by hand.
  • test-mounted-hosts.js: every mounted host must route both /osa/* and /osa*, and must not have an exact /osa route; route hosts are de-duplicated now that each host has two routes.
  • test-routing.js: the bare path redirects on both hosts and keeps the query; its preflight is answered, not redirected; /osafoo and /osafoo/chat are 404 on a mounted host and an ordinary community path on an unmounted one; /osa/ still serves the root.

Tested

  • bun workers/osa-worker/test-routing.js: 147 pass
  • bun workers/osa-worker/test-mounted-hosts.js: 18 pass
  • wrangler deploy --dry-run, top level and --env dev
  • Mutations: removing the redirect fails 7 routing tests; dropping the outside-the-mount 404 fails 4; an exact /osa route fails 3 mounted-hosts pins; removing the dev bare route fails 1
  • The unit tests call worker.fetch() directly and cannot exercise Cloudflare's route dispatch, so the query-string case is proven only after deploy (below)

After merge

  • sync-worker-cors.yml deploys the dev worker; on develop-widget.osc.earth, curl -sI of /osa answers 308 to /osa/, /osa?x=1 answers 308 to /osa/?x=1, and /osafoo answers 404 from the worker, not 522
  • After the release, the same three on widget.osc.earth
  • The Apache redirect applied on the server; curl -sI https://api.osc.earth/osa answers 308

A mounted host's /osa/* route does not match /osa, which reached the
placeholder origin and answered 522 (#500). Each host now also routes
the bare path, and the worker redirects it to /osa/ with its query.
The Apache config redirects /osa and /osa-dev the same way.

Tested: bun workers/osa-worker/test-routing.js (139 pass),
test-mounted-hosts.js (16 pass); removing the redirect fails 7 routing
tests, removing a bare route fails the mounted-hosts pin.
A route pattern without a trailing wildcard never matches a URL with a
query string, so the exact /osa route still left /osa?x=1 at 522. Each
mounted host now routes /osa*; the worker 404s the /osafoo paths that
route also delivers, rather than reading them as a community.

Tested: test-routing.js 147 pass, test-mounted-hosts.js 18 pass,
wrangler deploy --dry-run for both environments; dropping the 404, an
exact /osa route, or the dev bare route each fail a test.
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Worker Deployment Required

Worker changes detected. After merging to main or develop, the workflow will automatically deploy the worker.

Manual deployment (if needed):

cd workers/osa-worker
wrangler deploy --env dev  # for develop branch
wrangler deploy            # for main branch

fetch() redirects the bare /osa before stripping, so the branch mapping
it to / could no longer run.

Tested: test-routing.js 147 pass, test-mounted-hosts.js 18 pass.
@neuromechanist
neuromechanist merged commit fde0ba3 into develop Sep 24, 2026
8 checks passed
@neuromechanist
neuromechanist deleted the fix/issue-500-bare-mount-path branch September 24, 2026 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant