Skip to content

⚙️ feat: Support multiple CORS origins via comma-separated UI_BASE_URL#27

Merged
AdaInTheLab merged 2 commits intomainfrom
feat/multi-origin-cors
Apr 16, 2026
Merged

⚙️ feat: Support multiple CORS origins via comma-separated UI_BASE_URL#27
AdaInTheLab merged 2 commits intomainfrom
feat/multi-origin-cors

Conversation

@AdaInTheLab
Copy link
Copy Markdown
Owner

Summary

Let UI_BASE_URL accept a comma-separated list of origins. All entries are added to the CORS allowlist; the first entry stays the "primary" origin used for OAuth redirects. Removes the hardcoded ironkitsune.tech entries from app.ts so adding new domains is a config-only change.

Changes

  • src/env.ts
    • New parseOriginList() helper — splits on comma, trims, drops trailing slash
    • UI_BASE_URL now resolves to the first entry in the list (preserves OAuth redirect behavior)
    • New UI_ALLOWED_ORIGINS: string[] exposes the full parsed list
  • src/app.ts
    • Removed hardcoded ironkitsune.tech + www.ironkitsune.tech entries
    • CORS allowlist now driven entirely by env.UI_ALLOWED_ORIGINS, falling back to http://localhost:5173 in dev

Deployment note

Prod .env must be updated on merge:

- UI_BASE_URL=https://thehumanpatternlab.com
+ UI_BASE_URL=https://thehumanpatternlab.com,https://ironkitsune.tech,https://www.ironkitsune.tech

Testing

  • npx tsc --noEmit — clean
  • npm test — 41/41 passing
  • Pre-commit hook passes

Breaking Changes

None — single-value UI_BASE_URL still works unchanged. Only behavior change: the hardcoded ironkitsune origins must now be listed in env.


Co-authored-by: Sage sage@thehumanpatternlab.com

Previously CORS allowed UI_BASE_URL plus two hardcoded ironkitsune.tech
origins. This meant adding a new domain required a code change and
deploy. Now UI_BASE_URL can be a comma-separated list and drives both
the CORS allowlist and the primary redirect URL.

Changes:
- env.ts: parse UI_BASE_URL as a list (trim, drop trailing slash)
- env.ts: export UI_ALLOWED_ORIGINS (all entries) and keep UI_BASE_URL
  as the first entry (used for OAuth redirects)
- app.ts: remove hardcoded ironkitsune.tech entries, use env list

Prod .env needs updating to:
UI_BASE_URL=https://thehumanpatternlab.com,https://ironkitsune.tech,https://www.ironkitsune.tech

Co-authored-by: Sage <sage@thehumanpatternlab.com>
@github-actions
Copy link
Copy Markdown

😼 Carmel Judgment Stamp™

🟪 Carmel Judgment Stamp™
😼💬 "Hmm. Acceptable… for now."

PR: #27⚙️ feat: Support multiple CORS origins via comma-separated UI_BASE_URL
Author: @AdaInTheLab

This automated judgment has been issued by the Chief Judgment Office (CJO).

The previous commit changed UI_BASE_URL to accept a comma-separated
list, but adminRoutes was still reading process.env.UI_BASE_URL raw.
With the new format that would produce a broken OAuth redirect like:
  https://thehumanpatternlab.com,https://ironkitsune.tech/admin/dashboard

Switch adminRoutes to use env.UI_BASE_URL (the parsed first entry),
so redirects go to the primary UI origin only.

Also:
- Remove dead uiOrigin variable in app.ts (no longer referenced)
- Fix .env.example: UI_BASE_URL default was pointing at the API port
  (8001), now points at Vite's default (5173) with documentation
  showing the comma-separated syntax

Co-authored-by: Sage <sage@thehumanpatternlab.com>
@AdaInTheLab AdaInTheLab merged commit 03dbae3 into main Apr 16, 2026
1 check passed
@AdaInTheLab AdaInTheLab deleted the feat/multi-origin-cors branch April 16, 2026 17:28
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