Closed deanthing closed 2 years ago
After adding both CORSMiddleware from FastApi and using SocketManager, which adds another CORS head, it results in the following error when trying to connect from the client:
The 'Access-Control-Allow-Origin' header contains multiple values 'http://localhost:4200, http://localhost:4200', but only one is allowed.
This is my fast api set up code:
app = FastAPI() app.add_middleware( CORSMiddleware, allow_origins=['http://localhost:4200'], allow_credentials=True, allow_methods=["*"], allow_headers=["*"], ) socket_manager = SocketManager(app=app, async_mode="asgi", cors_allowed_origins="*")
The first CORS middleware access is so that the client can query the API but then the socketmanager also adds its own header.
Any solutions / help would be much appreciated!
As per a previous comment, setting cors_allowed_origins=[] in the SocketManager constructor fixes this issue.
cors_allowed_origins=[]
After adding both CORSMiddleware from FastApi and using SocketManager, which adds another CORS head, it results in the following error when trying to connect from the client:
This is my fast api set up code:
The first CORS middleware access is so that the client can query the API but then the socketmanager also adds its own header.
Any solutions / help would be much appreciated!