feat: use CORS origin regex for Tailscale domain #19
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "18-use-cors-origin-regex-for-tailscale-doma"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Replaces the hardcoded CORS origin list with
allow_origin_regexmatching any*.tail5b443a.ts.nethostname. Eliminates the need to update CORS configuration and redeploy the API every time a new Tailscale dev funnel is created.Changes
src/mcd_tracker_api/config.py: Addedtailscale_domainsetting (defaulttail5b443a.ts.net) to the pydantic-settingsSettingsclass, configurable viaMCD_TRACKER_TAILSCALE_DOMAINenv var.src/mcd_tracker_api/main.py: Replaced three hardcoded Tailscale origins with a singleallow_origin_regexbuilt fromsettings.tailscale_domainusingre.escape. Non-Tailscale origins (capacitor://localhost,http://localhost,http://localhost:5173) remain as explicitallow_originsentries.Test Plan
https://.*\.tail5b443a\.ts\.netReview Checklist
Related
Review -- Pass
Reviewed the 2-file diff. No issues found.
config.py: New
tailscale_domainsetting follows existing pydantic-settings pattern, correctMCD_TRACKER_prefix, sensible default.main.py:
re.escapeproperly escapes dots in the domain for regex safety.allow_origin_regexis the correct CORSMiddleware parameter. Non-Tailscale origins remain as explicitallow_origins. Minimal and correct.No fixes needed. Ready for merge.