Skip to content

Commit be6928a

Browse files
committed
Enable CORS for run_simulation_stream endpoint
1 parent 988e4e4 commit be6928a

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1919
- Added unit tests for the streaming endpoint
2020
- Modified `simulator.hpp` to flush stdout after each line for better streaming support (see `src/README.md`)
2121
- Improved help endpoint with more concise documentation
22+
- Enabled CORS only for `/run_simulation_stream` endpoint to allow controlled API access
2223

2324
### Changed
2425
- Standardized API response format for better consistency:

backend.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22
# A Flask API for running Flex Net Sim network simulations
33

44
from flask import Flask, request, Response, stream_with_context
5+
from flask_cors import CORS
56
from utils.helpers import *
67

78
# --- Flask Application Setup ---
89
app = Flask(__name__)
9-
#CORS(app, resources={r"/run_simulation": {"origins": 'http://localhost:5000'}})
10+
11+
# Enable CORS only for /run_simulation_stream
12+
CORS(app, resources={r"/run_simulation_stream": {"origins": "*"}})
1013

1114
@app.route("/run_simulation", methods=["POST"])
1215
def run_simulation():

0 commit comments

Comments
 (0)