cors.py python
21 lines 581 B
Raw
sha256:a78e7e5a8740e03315f325d19edeb3aa1b306b3337d04abbaa9a9e0f3bbeb7a1 docs: MuseHub-first before ISR #74 — staging solidify NEXT Human 1 day 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:a78e7e5a8740e03315f325d19edeb3aa1b306b3337d04abbaa9a9e0f3bbeb7a1 docs: MuseHub-first before ISR #74 — staging solidify NEXT Human 1 day ago