cors.py python
21 lines 581 B
Raw
sha256:f88ec0083b3bcac6a4b7b99c8cc196194ef376aab2c4f2f63e8dfe26256ac6b7 docs: reconcile v1 prerelease publication and operating guides Human 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 1 commit
sha256:f88ec0083b3bcac6a4b7b99c8cc196194ef376aab2c4f2f63e8dfe26256ac6b7 docs: reconcile v1 prerelease publication and operating guides Human 8 days ago