From 0b29f9a7ee34287fa316064b165020880071d9d5 Mon Sep 17 00:00:00 2001 From: Eugene Yurtsev Date: Thu, 21 Mar 2024 21:02:35 -0400 Subject: [PATCH] x --- backend/server/main.py | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/backend/server/main.py b/backend/server/main.py index f6eb952..befdd41 100644 --- a/backend/server/main.py +++ b/backend/server/main.py @@ -3,13 +3,10 @@ import os from pathlib import Path -from fastapi import FastAPI, Request, Response +from fastapi import FastAPI from fastapi.middleware.cors import CORSMiddleware from fastapi.staticfiles import StaticFiles from langserve import add_routes -from starlette.middleware.base import BaseHTTPMiddleware, RequestResponseEndpoint -from starlette.responses import Response -import uuid from server.api import configurables, examples, extract, extractors, shared, suggest from server.extraction_runnable import ( @@ -33,24 +30,6 @@ ) -class EnsureUserIDMiddleware(BaseHTTPMiddleware): - async def dispatch( - self, request: Request, call_next: RequestResponseEndpoint - ) -> Response: - user_id = request.cookies.get("user_id") - if not user_id: - user_id = str(uuid.uuid4()) # Generate a new user_id - request.state.user_id = user_id # Set user_id in request state - response = await call_next(request) - response.set_cookie(key="user_id", value=user_id, httponly=True) - else: - request.state.user_id = user_id # Set existing user_id in request state - response = await call_next(request) - return response - - -app.add_middleware(EnsureUserIDMiddleware) - ROOT = Path(__file__).parent.parent ORIGINS = os.environ.get("CORS_ORIGINS", "").split(",")