lvwerra HF Staff commited on
Commit
f6a5b9f
·
verified ·
1 Parent(s): 3ce5b7e

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -108,8 +108,13 @@ app.add_middleware(
108
  secret_key=SESSION_SECRET,
109
  session_cookie="hp_session",
110
  max_age=60 * 60 * 24 * 30, # 30 days
111
- https_only=False, # works in local dev; HF terminates TLS upstream
112
- same_site="lax",
 
 
 
 
 
113
  )
114
 
115
 
 
108
  secret_key=SESSION_SECRET,
109
  session_cookie="hp_session",
110
  max_age=60 * 60 * 24 * 30, # 30 days
111
+ # On HF Spaces the dashboard runs inside an iframe at huggingface.co, so
112
+ # the Space's own cookies are "cross-site" relative to the parent page.
113
+ # SameSite=None + Secure is the only combination browsers allow in that
114
+ # context. We toggle based on OAuth being configured (i.e. deployed to a
115
+ # real Space) so local dev keeps working over plain HTTP.
116
+ same_site="none" if OAUTH_CLIENT_ID else "lax",
117
+ https_only=bool(OAUTH_CLIENT_ID),
118
  )
119
 
120