Skip to content

Drop dead osa-demo.pages.dev origin allowlist entries - #626

Merged
neuromechanist merged 4 commits into
developfrom
feature/issue-625-drop-osa-demo-pages-dev
Oct 27, 2026
Merged

neuromechanist merged 4 commits into
developfrom
feature/issue-625-drop-osa-demo-pages-dev

Conversation

@neuromechanist

Copy link
Copy Markdown
Member

Closes #625

Why these entries are dead

frontend/index.html redirects every osa-demo.pages.dev and <branch>.osa-demo.pages.dev visit to demo.osc.earth or <branch>-demo.osc.earth.
The redirect is the first script in <head>, ahead of osa-chat-widget.js and the page script that calls the API, so the demo never calls the API or embeds a notebook from a pages.dev origin.
The *.pages.dev name is also account-scoped: after the move to another Cloudflare account the Pages project gets a suffixed name (osa-demo-<suffix>.pages.dev), so the literal entries would allow a name the project no longer owns.

What changed

  • src/api/main.py: drop https://osa-demo.pages.dev and https://*.osa-demo.pages.dev from the default CORS origins; the docstring now lists the actual defaults.
  • src/api/routers/community.py: drop both from the platform origins _is_authorized_origin accepts for widget requests.
  • workers/osa-worker/index.js: drop both from isAllowedOrigin.
  • scripts/sync_worker_cors.py: drop both from the template that regenerates isAllowedOrigin, so a CORS sync does not put them back (running the script reports "No changes needed").
  • scripts/build_notebook_site.py: drop both from the notebook frame-ancestors (production and develop).

What is kept, and why

  • https://osa-dash.pages.dev and https://*.osa-dash.pages.dev stay in the backend CORS defaults: dashboard PR previews are served there and call the API. A test now pins them.
  • The hostname redirect logic in frontend/index.html and frontend/osa-chat-widget.js is untouched; it is how pages.dev visitors reach the custom domains.
  • tests/test_core/test_config/test_community.py keeps https://*.osa-demo.pages.dev as sample input to the CommunityConfig.cors_origins validator; it does not allow anything.

Tests

  • Backend CORS: the removed origins get no Access-Control-Allow-Origin, are absent from _collect_cors_config, and are refused by _is_authorized_origin; an osa-dash.pages.dev preview is still allowed. The wildcard-to-regex helper test now uses https://*.example.pages.dev.
  • Worker: the CORS preflight answers the demo.osc.earth fallback, not the asking origin, for both removed names, and still echoes demo.osc.earth and develop-demo.osc.earth.
  • Notebook: neither environment's frame-ancestors contains an osa-demo.pages.dev source.
  • The new assertions fail against the previous source (8 Python, 2 worker), and pass now.
  • uv run pytest tests/ -q (Python 3.12): 5367 passed, 83 skipped, 2 failed, both unrelated to this change: test_documentation_urls_accessible[fieldtrip] hit a raw.githubusercontent.com read timeout and passes on rerun, and test_real_program_suggests_a_schema_tag runs only where a local hed-lsp checkout exists (skipped in CI)
  • bun workers/osa-worker/test-routing.js: 162 passed; bun workers/osa-worker/test-mounted-hosts.js: 37 passed
  • uv run ruff check . and ruff format --check clean

frontend/index.html redirects every osa-demo.pages.dev visit to the
osc.earth custom domains before any script calls the API, and the
pages.dev name is account-scoped. Keep osa-dash.pages.dev for dashboard
PR previews. Tests assert the removed origins are refused.

Refs #625
Also from the sync_worker_cors.py template that regenerates it, so a
sync does not restore it. The routing test now checks the preflight
refuses both names and still allows the demo hosts.

Refs #625
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