From 9ce9de3a33b34eff52a2de95e8e5e59ef45056ad Mon Sep 17 00:00:00 2001 From: kx1t <15090643+kx1t@users.noreply.github.com> Date: Wed, 9 Apr 2025 11:11:59 -0400 Subject: [PATCH] Add CORS support for reverse web proxies --- auto_rx/autorx/web.py | 6 ++++-- auto_rx/requirements.txt | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/auto_rx/autorx/web.py b/auto_rx/autorx/web.py index 954050d..241e0cc 100644 --- a/auto_rx/autorx/web.py +++ b/auto_rx/autorx/web.py @@ -38,6 +38,7 @@ from queue import Queue from threading import Thread import flask from flask import request, abort, make_response, send_file +from flask_cors import CORS from flask_socketio import SocketIO from werkzeug.middleware.proxy_fix import ProxyFix @@ -56,9 +57,10 @@ app.jinja_env.auto_reload = True flask_app_thread = None # A key that needs to be matched to allow shutdown. flask_shutdown_key = None - +# allow all CORS: +cors = CORS(app, resources={r"/*": {"origins": "*"}}) # SocketIO instance -socketio = SocketIO(app, async_mode="threading") +socketio = SocketIO(app, async_mode="threading", cors_allowed_origins="*") # Global store of telemetry data, which we will add data to and manage. # Under each key (which will be the sonde ID), we will have a dictionary containing: diff --git a/auto_rx/requirements.txt b/auto_rx/requirements.txt index 6ceef4b..8c2bf2f 100644 --- a/auto_rx/requirements.txt +++ b/auto_rx/requirements.txt @@ -1,6 +1,7 @@ python-dateutil flask flask-socketio +flask-cors numpy requests semver