Commit ·
923cd47
1
Parent(s): a616809
fix CORS issue
Browse files- server/app.py +9 -0
server/app.py
CHANGED
|
@@ -13,6 +13,7 @@ import os
|
|
| 13 |
from typing import Any, Dict, Optional
|
| 14 |
|
| 15 |
from fastapi import FastAPI, HTTPException
|
|
|
|
| 16 |
from pydantic import BaseModel, Field
|
| 17 |
|
| 18 |
from openenv.core.env_server.http_server import HTTPEnvServer
|
|
@@ -63,6 +64,7 @@ class StepBody(BaseModel):
|
|
| 63 |
# ---------------------------------------------------------------------------
|
| 64 |
|
| 65 |
def create_app() -> FastAPI:
|
|
|
|
| 66 |
app = FastAPI(
|
| 67 |
title="API Contract Debugger",
|
| 68 |
description=(
|
|
@@ -72,6 +74,13 @@ def create_app() -> FastAPI:
|
|
| 72 |
version="1.0.0",
|
| 73 |
)
|
| 74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
# ------------------------------------------------------------------
|
| 76 |
# 1. Our stateful routes — registered FIRST
|
| 77 |
# ------------------------------------------------------------------
|
|
|
|
| 13 |
from typing import Any, Dict, Optional
|
| 14 |
|
| 15 |
from fastapi import FastAPI, HTTPException
|
| 16 |
+
from fastapi.middleware.cors import CORSMiddleware
|
| 17 |
from pydantic import BaseModel, Field
|
| 18 |
|
| 19 |
from openenv.core.env_server.http_server import HTTPEnvServer
|
|
|
|
| 64 |
# ---------------------------------------------------------------------------
|
| 65 |
|
| 66 |
def create_app() -> FastAPI:
|
| 67 |
+
|
| 68 |
app = FastAPI(
|
| 69 |
title="API Contract Debugger",
|
| 70 |
description=(
|
|
|
|
| 74 |
version="1.0.0",
|
| 75 |
)
|
| 76 |
|
| 77 |
+
app.add_middleware(
|
| 78 |
+
CORSMiddleware,
|
| 79 |
+
allow_origins=["*"],
|
| 80 |
+
allow_methods=["GET", "POST", "OPTIONS"],
|
| 81 |
+
allow_headers=["Content-Type", "Authorization"],
|
| 82 |
+
)
|
| 83 |
+
|
| 84 |
# ------------------------------------------------------------------
|
| 85 |
# 1. Our stateful routes — registered FIRST
|
| 86 |
# ------------------------------------------------------------------
|