From 0453d1419efb01b4f020090a2056e9abe83153ce Mon Sep 17 00:00:00 2001 From: "Andres D. Molins" Date: Thu, 29 Feb 2024 12:26:05 +0100 Subject: [PATCH] Problem: Diagnostic VM API isn't accessible through frontend. Solution: Implement CORS policy headers on diagnostic VM endpoints. --- examples/example_fastapi/main.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/examples/example_fastapi/main.py b/examples/example_fastapi/main.py index b6861b307..0f9195f7e 100644 --- a/examples/example_fastapi/main.py +++ b/examples/example_fastapi/main.py @@ -11,6 +11,7 @@ import aiohttp from fastapi import FastAPI +from fastapi.middleware.cors import CORSMiddleware from fastapi.responses import PlainTextResponse from pip._internal.operations.freeze import freeze from pydantic import BaseModel @@ -27,6 +28,13 @@ http_app = FastAPI() app = AlephApp(http_app=http_app) +app.add_middleware( + CORSMiddleware, + allow_credentials=True, + allow_origins=["*"], + allow_methods=["*"], + allow_headers=["*"], +) cache = VmCache() startup_lifespan_executed: bool = False