feat: add CORS middleware to allow cross-origin requests for waveform viewer

This commit is contained in:
Brian Harrison
2026-04-03 14:50:43 -04:00
parent 8941dd0aef
commit 23e4febba6
2 changed files with 11 additions and 1 deletions

View File

@@ -41,6 +41,7 @@ from typing import Optional
# FastAPI / Pydantic
try:
from fastapi import FastAPI, HTTPException, Query
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import JSONResponse
import uvicorn
except ImportError:
@@ -75,6 +76,15 @@ app = FastAPI(
version="0.1.0",
)
# Allow requests from the waveform viewer opened as a local file (file://)
# and from any dev server or terra-view proxy.
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_methods=["GET", "POST"],
allow_headers=["*"],
)
# ── Serialisers ────────────────────────────────────────────────────────────────
# Plain dict helpers — avoids a Pydantic dependency in the library layer.