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

@@ -322,7 +322,7 @@ class MiniMateClient:
) )
a5_frames = proto.read_bulk_waveform_stream( a5_frames = proto.read_bulk_waveform_stream(
event._waveform_key, stop_after_metadata=False event._waveform_key, stop_after_metadata=False, max_chunks=128
) )
log.info( log.info(

View File

@@ -41,6 +41,7 @@ from typing import Optional
# FastAPI / Pydantic # FastAPI / Pydantic
try: try:
from fastapi import FastAPI, HTTPException, Query from fastapi import FastAPI, HTTPException, Query
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import JSONResponse from fastapi.responses import JSONResponse
import uvicorn import uvicorn
except ImportError: except ImportError:
@@ -75,6 +76,15 @@ app = FastAPI(
version="0.1.0", 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 ──────────────────────────────────────────────────────────────── # ── Serialisers ────────────────────────────────────────────────────────────────
# Plain dict helpers — avoids a Pydantic dependency in the library layer. # Plain dict helpers — avoids a Pydantic dependency in the library layer.