You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.
Hello humans,
I faced an issue when I was trying to use fastapi-socketio and the CORSMiddleware
app = FastAPI()
sio = SocketManager(app=app)
# CORS
# Set all CORS enabled origins
if config.BACKEND_CORS_ORIGINS:
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
and this error was showing up
The workaround I found was to set to an empty list the cors_allowed_origins parameter on the SocketManager to prevent the duplication of the values
Solution
app = FastAPI()
sio = SocketManager(app=app, cors_allowed_origins=[])
# CORS
# Set all CORS enabled origins
if config.BACKEND_CORS_ORIGINS:
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
Hey @niteshgaba,
mmm I don't know how to help you, I remember I have to dig into the source code and the issue mentioned above to find the workaround and I just worked.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hello humans,
I faced an issue when I was trying to use fastapi-socketio and the CORSMiddleware
and this error was showing up
The workaround I found was to set to an empty list the
cors_allowed_origins
parameter on the SocketManager to prevent the duplication of the valuesSolution
The solution was taken from here
if I have some time, I will try to fix it,
Cheers
The text was updated successfully, but these errors were encountered: