diff --git a/app/server.py b/app/server.py index 1cfb0d3..ba59990 100644 --- a/app/server.py +++ b/app/server.py @@ -6,6 +6,7 @@ import signal import sys from threading import Thread from time import sleep +from flask_cors import CORS import ntcore import waitress @@ -25,7 +26,8 @@ signal.signal(signal.SIGINT, signal_handler) # initialize flask app and socketio app = Flask(__name__, static_folder="dist", static_url_path="/") -socketio = SocketIO(app) +CORS(app) +socketio = SocketIO(app, cors_allowed_origins="*") inst = ntcore.NetworkTableInstance.getDefault() table = inst.getTable("SmartDashboard") diff --git a/client/src/lib/utils/initializeTelemetry.ts b/client/src/lib/utils/initializeTelemetry.ts index a20377e..1782ade 100644 --- a/client/src/lib/utils/initializeTelemetry.ts +++ b/client/src/lib/utils/initializeTelemetry.ts @@ -25,7 +25,7 @@ export const initializeTelemetry = ( ) } - const socket = io() + const socket = io('localhost:1280') socket.on('connect', () => { console.log('Socket-IO connected!') socket.emit('subscribe', topics) diff --git a/poetry.lock b/poetry.lock index f66a2ee..994f708 100644 --- a/poetry.lock +++ b/poetry.lock @@ -107,6 +107,20 @@ Werkzeug = ">=3.0.0" async = ["asgiref (>=3.2)"] dotenv = ["python-dotenv"] +[[package]] +name = "flask-cors" +version = "4.0.0" +description = "A Flask extension adding a decorator for CORS support" +optional = false +python-versions = "*" +files = [ + {file = "Flask-Cors-4.0.0.tar.gz", hash = "sha256:f268522fcb2f73e2ecdde1ef45e2fd5c71cc48fe03cffb4b441c6d1b40684eb0"}, + {file = "Flask_Cors-4.0.0-py2.py3-none-any.whl", hash = "sha256:bc3492bfd6368d27cfe79c7821df5a8a319e1a6d5eab277a3794be19bdc51783"}, +] + +[package.dependencies] +Flask = ">=0.9" + [[package]] name = "flask-socketio" version = "5.3.6" @@ -556,4 +570,4 @@ h11 = ">=0.9.0,<1" [metadata] lock-version = "2.0" python-versions = "^3.12" -content-hash = "3afde2c87621fc59faa4e33e0384a7dd132ac8b1471c1fa3e62dadcce0660dde" +content-hash = "231c9d57b5d81f58f755c4564ca2de3e2b1533ffa560f9cb6d12be3c13130260" diff --git a/pyproject.toml b/pyproject.toml index d69cd3a..60b2c33 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,6 +14,7 @@ flask-socketio = '^5.3.6' eventlet = '^0.34.3' flaskwebgui = '^1.0.8' waitress = '^2.1.2' +flask-cors = "^4.0.0" [tool.poetry.group.dev.dependencies] ruff = '^0.2.2'