I'm hitting a 403 locally. Been trying to debug for days.
from flask_socketio import SocketIO
from flask_cors import CORS
from fastapi import FastAPI, WebSocket, Depends
from fastapi_socketio import SocketManager
from fastapi.middleware.cors import CORSMiddleware
from fastapi.staticfiles import StaticFiles
from fastapi.responses import FileResponse
I'm hitting a 403 locally. Been trying to debug for days.
from flask_socketio import SocketIO from flask_cors import CORS from fastapi import FastAPI, WebSocket, Depends from fastapi_socketio import SocketManager from fastapi.middleware.cors import CORSMiddleware from fastapi.staticfiles import StaticFiles from fastapi.responses import FileResponse
app = FastAPI() app.mount("/static", StaticFiles(directory="front/build", html=True), name="static")
socket_manager = SocketManager(app=app)
Set CORS
origins = [ "http://localhost:3000" ]
app.add_middleware( CORSMiddleware, allow_origins=origins, allow_credentials=True, allow_methods=[""], allow_headers=[""], )
GAME_NAMESPACE = "/game"
if name == "main":
LOCAL
On Client: const SERVER_URL = 'http://127.0.0.1:5001'; const GAME_NAMESPACE = '/game';
To run locally I'm using: uvicorn server:app --reload --port 5001.
ERRORS: WebSocket connection to 'ws://127.0.0.1:5001/socket.io/?EIO=4&transport=websocket' failed INFO: ('127.0.0.1', 51879) - "WebSocket /socket.io/?EIO=4&transport=websocket" 403 INFO: connection failed (403 Forbidden) INFO: connection closed
Any ideas?