Spaces:
Configuration error
Configuration error
github-actions[bot] commited on
Commit ·
66cfdc7
1
Parent(s): f5b927a
Sync backend files from GitHub c72593b
Browse filesDeployed-From: c72593b6f98884707856c32fd592db2f84874210
main.py
CHANGED
|
@@ -676,12 +676,13 @@ def unscoped(ws: str, key: str) -> Optional[str]:
|
|
| 676 |
def get_index(request: Request):
|
| 677 |
response = FileResponse(resource_path("index.html"))
|
| 678 |
if not is_workspace_id(request.cookies.get(WORKSPACE_COOKIE)):
|
| 679 |
-
# HF's proxy terminates TLS
|
| 680 |
-
# SameSite=None
|
| 681 |
-
|
|
|
|
| 682 |
response.set_cookie(
|
| 683 |
WORKSPACE_COOKIE, uuid.uuid4().hex, max_age=365 * 24 * 3600, httponly=True,
|
| 684 |
-
secure=
|
| 685 |
)
|
| 686 |
return response
|
| 687 |
|
|
|
|
| 676 |
def get_index(request: Request):
|
| 677 |
response = FileResponse(resource_path("index.html"))
|
| 678 |
if not is_workspace_id(request.cookies.get(WORKSPACE_COOKIE)):
|
| 679 |
+
# Deployed, the site is always HTTPS (HF's proxy terminates TLS and doesn't say so),
|
| 680 |
+
# and SameSite=None lets the cookie work inside the huggingface.co Space iframe.
|
| 681 |
+
# Local http dev keeps a plain Lax cookie.
|
| 682 |
+
secure = request.url.hostname not in ("localhost", "127.0.0.1")
|
| 683 |
response.set_cookie(
|
| 684 |
WORKSPACE_COOKIE, uuid.uuid4().hex, max_age=365 * 24 * 3600, httponly=True,
|
| 685 |
+
secure=secure, samesite="none" if secure else "lax",
|
| 686 |
)
|
| 687 |
return response
|
| 688 |
|