Skip to content

Commit 88bd5ec

Browse files
authored
Enable CORS for Code Interpreter Server (#242)
1 parent 52cce19 commit 88bd5ec

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

.changeset/stale-forks-lay.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@e2b/code-interpreter-template': patch
3+
---
4+
5+
allow cors

template/server/main.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
from contextlib import asynccontextmanager
88
from fastapi import FastAPI, Request
9+
from fastapi.middleware.cors import CORSMiddleware
910
from fastapi.responses import PlainTextResponse
1011

1112
from api.models.context import Context
@@ -60,6 +61,13 @@ async def lifespan(app: FastAPI):
6061

6162
app = FastAPI(lifespan=lifespan)
6263

64+
app.add_middleware(
65+
CORSMiddleware,
66+
allow_origins=["*"],
67+
allow_methods=["*"],
68+
allow_headers=["*"],
69+
)
70+
6371
logger.info("Starting Code Interpreter server")
6472

6573

0 commit comments

Comments
 (0)