cors.py
python
sha256:106ef9e12cca7f3be3ffb2a6bd3abfa76f032dce453c9e5010d732a8d86f2e14
Reconcile reviewed credential compatibility 32254cd939885d9…
Human
patch
8 days ago
| 1 | """CORS policy for the local app server (§Q0.5).""" |
| 2 | |
| 3 | from __future__ import annotations |
| 4 | |
| 5 | |
| 6 | def allowed_origins(port: int) -> frozenset[str]: |
| 7 | """Return the frozen allowlist of browser origins.""" |
| 8 | return frozenset( |
| 9 | { |
| 10 | f"http://127.0.0.1:{port}", |
| 11 | f"http://localhost:{port}", |
| 12 | f"http://[::1]:{port}", |
| 13 | } |
| 14 | ) |
| 15 | |
| 16 | |
| 17 | def origin_allowed(origin: str | None, port: int) -> bool: |
| 18 | """Return whether ``origin`` is permitted for this server instance.""" |
| 19 | if not origin: |
| 20 | return True |
| 21 | return origin in allowed_origins(port) |
File History
2 commits
sha256:106ef9e12cca7f3be3ffb2a6bd3abfa76f032dce453c9e5010d732a8d86f2e14
Reconcile reviewed credential compatibility 32254cd939885d9…
Human
patch
8 days ago
sha256:c87cf2c2f03da507f66f93922cb339a2cbebb33ad6372a6039032fb09a20da12
Reconcile reviewed Overseer recovery d47291d5d9030de5ebef71…
Human
minor
⚠
9 days ago