cors.py python
21 lines 581 B
Raw
sha256:8d7f41aafae41deee70035a92f93602ef1722a290153597451e5932af503a42c docs: queue board-identity follow-ups so they survive the session Human 3 hours 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 1 commit
sha256:8d7f41aafae41deee70035a92f93602ef1722a290153597451e5932af503a42c docs: queue board-identity follow-ups so they survive the session Human 3 hours ago