Spaces:
Sleeping
Sleeping
Commit
·
0c09303
1
Parent(s):
d786593
updated backend for cookies
Browse files- evolutiontransformer/api.py +7 -5
- frontend/src/App.jsx +0 -3
evolutiontransformer/api.py
CHANGED
|
@@ -22,7 +22,10 @@ app = FastAPI()
|
|
| 22 |
|
| 23 |
app.add_middleware(
|
| 24 |
CORSMiddleware,
|
| 25 |
-
allow_origins=[
|
|
|
|
|
|
|
|
|
|
| 26 |
allow_credentials=True,
|
| 27 |
allow_methods=["*"],
|
| 28 |
allow_headers=["*"],
|
|
@@ -53,13 +56,12 @@ def get_session_id(request: Request, response: Response):
|
|
| 53 |
if not session_id:
|
| 54 |
session_id = str(uuid.uuid4())
|
| 55 |
print(f"Generated new session_id: {session_id}")
|
| 56 |
-
# Set cookie with appropriate settings
|
| 57 |
response.set_cookie(
|
| 58 |
key="session_id",
|
| 59 |
value=session_id,
|
| 60 |
-
httponly=True,
|
| 61 |
-
secure=True,
|
| 62 |
-
samesite="
|
| 63 |
)
|
| 64 |
|
| 65 |
return session_id
|
|
|
|
| 22 |
|
| 23 |
app.add_middleware(
|
| 24 |
CORSMiddleware,
|
| 25 |
+
allow_origins=[
|
| 26 |
+
"http://localhost:5173",
|
| 27 |
+
"https://tcmmichaelb139-evolutiontransformer.hf.space",
|
| 28 |
+
], # Allow all origins for now to debug
|
| 29 |
allow_credentials=True,
|
| 30 |
allow_methods=["*"],
|
| 31 |
allow_headers=["*"],
|
|
|
|
| 56 |
if not session_id:
|
| 57 |
session_id = str(uuid.uuid4())
|
| 58 |
print(f"Generated new session_id: {session_id}")
|
|
|
|
| 59 |
response.set_cookie(
|
| 60 |
key="session_id",
|
| 61 |
value=session_id,
|
| 62 |
+
httponly=True,
|
| 63 |
+
secure=True,
|
| 64 |
+
samesite="none",
|
| 65 |
)
|
| 66 |
|
| 67 |
return session_id
|
frontend/src/App.jsx
CHANGED
|
@@ -23,15 +23,12 @@ function App() {
|
|
| 23 |
|
| 24 |
const loadModels = async () => {
|
| 25 |
try {
|
| 26 |
-
console.log("Loading models...");
|
| 27 |
const taskId = await fetchModels();
|
| 28 |
-
console.log("Got task ID:", taskId);
|
| 29 |
|
| 30 |
if (taskId) {
|
| 31 |
checkTaskStatus(
|
| 32 |
taskId,
|
| 33 |
(result) => {
|
| 34 |
-
console.log("Models loaded successfully:", result);
|
| 35 |
if (result && Array.isArray(result.response)) {
|
| 36 |
setModels(result.response);
|
| 37 |
}
|
|
|
|
| 23 |
|
| 24 |
const loadModels = async () => {
|
| 25 |
try {
|
|
|
|
| 26 |
const taskId = await fetchModels();
|
|
|
|
| 27 |
|
| 28 |
if (taskId) {
|
| 29 |
checkTaskStatus(
|
| 30 |
taskId,
|
| 31 |
(result) => {
|
|
|
|
| 32 |
if (result && Array.isArray(result.response)) {
|
| 33 |
setModels(result.response);
|
| 34 |
}
|