Spaces:
Running
Running
David Ko
commited on
Commit
Β·
d1b4a04
1
Parent(s):
dfdf7e7
Use SameSite=None for session/remember cookies (iframe compatibility on Spaces)
Browse files
api.py
CHANGED
@@ -33,9 +33,16 @@ from chromadb.utils import embedding_functions
|
|
33 |
app = Flask(__name__, static_folder='static')
|
34 |
app.secret_key = 'your_secret_key_here' # μΈμ
μνΈνλ₯Ό μν λΉλ° ν€
|
35 |
app.config['CORS_HEADERS'] = 'Content-Type'
|
36 |
-
|
37 |
-
app.config['
|
|
|
38 |
app.config['REMEMBER_COOKIE_HTTPONLY'] = True
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
CORS(app) # Enable CORS for all routes
|
40 |
|
41 |
# μν¬λ¦Ώ ν€ μ€μ (μΈμ
μνΈνμ μ¬μ©)
|
@@ -1183,7 +1190,7 @@ def login():
|
|
1183 |
print(f"Redirecting to: {next_page}")
|
1184 |
return redirect(next_page)
|
1185 |
print("Redirecting to index.html")
|
1186 |
-
return redirect('
|
1187 |
else:
|
1188 |
error = 'Invalid username or password'
|
1189 |
print(f"Login failed: {error}")
|
|
|
33 |
app = Flask(__name__, static_folder='static')
|
34 |
app.secret_key = 'your_secret_key_here' # μΈμ
μνΈνλ₯Ό μν λΉλ° ν€
|
35 |
app.config['CORS_HEADERS'] = 'Content-Type'
|
36 |
+
# Remember cookie (Flask-Login)
|
37 |
+
app.config['REMEMBER_COOKIE_DURATION'] = timedelta(days=30)
|
38 |
+
app.config['REMEMBER_COOKIE_SECURE'] = True # Spaces uses HTTPS
|
39 |
app.config['REMEMBER_COOKIE_HTTPONLY'] = True
|
40 |
+
app.config['REMEMBER_COOKIE_SAMESITE'] = 'None'
|
41 |
+
# Session cookie (Flask-Session)
|
42 |
+
app.config['SESSION_COOKIE_SECURE'] = True # HTTPS
|
43 |
+
app.config['SESSION_COOKIE_HTTPONLY'] = True
|
44 |
+
app.config['SESSION_COOKIE_SAMESITE'] = 'None'
|
45 |
+
app.config['SESSION_COOKIE_PATH'] = '/'
|
46 |
CORS(app) # Enable CORS for all routes
|
47 |
|
48 |
# μν¬λ¦Ώ ν€ μ€μ (μΈμ
μνΈνμ μ¬μ©)
|
|
|
1190 |
print(f"Redirecting to: {next_page}")
|
1191 |
return redirect(next_page)
|
1192 |
print("Redirecting to index.html")
|
1193 |
+
return redirect(url_for('serve_index_html'))
|
1194 |
else:
|
1195 |
error = 'Invalid username or password'
|
1196 |
print(f"Login failed: {error}")
|