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.
(This may be a documentation issue -- in any case, this may be helpful to someone else)
EDIT
I see this problem is mentioned in issue #2, but I didn't make the connection until after creating this issue.
I encountered a problem where Chrome refused to upgrade the connection, due to multiple CORS header being returned in the server response, when using fastapi.CORSMiddleware and setting allowed origins in both places
app=FastAPI()
app.add_middleware(
CORSMiddleware,
# allow any origin for development purposes, don't do this in productionallow_origins=['*'],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
sio=SocketManager(app=app, cors_allowed_origins=['*'])
Seem obvious now, but setting both allow_origins in CORSMiddleware, and cors_allowed_origins in fastapi-socketio causes duplicate headers to be returned to the client (which causes errors in Chrome, and the connection isn't upgraded)
The text was updated successfully, but these errors were encountered:
inactivist
changed the title
multiple access-control-allow-origin header entries returned to client; chrome fails to upgrade connection.
CORS configuration: multiple access-control-allow-origin header entries returned to client; chrome fails to upgrade connection.
Dec 14, 2020
inactivist
changed the title
CORS configuration: multiple access-control-allow-origin header entries returned to client; chrome fails to upgrade connection.
[USAGE-NOTE] CORS configuration: multiple access-control-allow-origin header entries returned to client; chrome fails to upgrade connection.
Dec 14, 2020
(This may be a documentation issue -- in any case, this may be helpful to someone else)
EDIT
I see this problem is mentioned in issue #2, but I didn't make the connection until after creating this issue.
I encountered a problem where Chrome refused to upgrade the connection, due to multiple CORS header being returned in the server response, when using
fastapi.CORSMiddleware
and setting allowed origins in both placesSeem obvious now, but setting both
allow_origins
inCORSMiddleware
, andcors_allowed_origins
infastapi-socketio
causes duplicate headers to be returned to the client (which causes errors in Chrome, and the connection isn't upgraded)Related to python-socketio issue 205 -- this response recommends
async_mode='sanic'
andcors_allowed_origins=[]
in the constructor:I've confirmed that passing
cors_allowed_origins=[]
in theSocketManager()
constructor resolves the issue in this situation.(See also this issue)
The text was updated successfully, but these errors were encountered: