tannuiscoding commited on
Commit
ade280d
Β·
1 Parent(s): 0b42fd6

Allow Hugging Face Spaces cookie sharing and CORS origins

Browse files
Files changed (1) hide show
  1. backend/__init__.py +5 -5
backend/__init__.py CHANGED
@@ -37,17 +37,17 @@ def create_app(config_override: dict | None = None) -> Flask:
37
  )
38
  app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
39
  app.config["SESSION_COOKIE_HTTPONLY"] = True
40
- app.config["SESSION_COOKIE_SAMESITE"] = "Lax"
41
  app.config["SESSION_COOKIE_SECURE"] = True
42
 
43
  if config_override:
44
  app.config.update(config_override)
45
 
46
- # ── Extensions ───────────────────────────────────────────────────────────
47
  db.init_app(app)
48
- default_origins = "http://localhost:5173,http://127.0.0.1:5173"
49
- CORS(app, supports_credentials=True,
50
- origins=os.environ.get("CORS_ORIGINS", default_origins).split(","))
51
 
52
  # ── Blueprints ───────────────────────────────────────────────────────────
53
  from .routes.auth import auth_bp
 
37
  )
38
  app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
39
  app.config["SESSION_COOKIE_HTTPONLY"] = True
40
+ app.config["SESSION_COOKIE_SAMESITE"] = "None"
41
  app.config["SESSION_COOKIE_SECURE"] = True
42
 
43
  if config_override:
44
  app.config.update(config_override)
45
 
46
+ # ── Extensions ───────────────────────────────────────────────────────
47
  db.init_app(app)
48
+ default_origins = "http://localhost:5173,http://127.0.0.1:5173,https://huggingface.co,https://hf.space"
49
+ origins = os.environ.get("CORS_ORIGINS", default_origins).split(",")
50
+ CORS(app, supports_credentials=True, origins=origins)
51
 
52
  # ── Blueprints ───────────────────────────────────────────────────────────
53
  from .routes.auth import auth_bp