mohsinramzan commited on
Commit
f92a401
·
1 Parent(s): 2d82c8b

Fixing the CORS Middle Ware

Browse files
Files changed (1) hide show
  1. main.py +9 -1
main.py CHANGED
@@ -2,9 +2,17 @@ from fastapi import FastAPI, Request
2
  from pydantic import BaseModel
3
  from typing import Dict
4
  import time
 
5
 
6
- app = FastAPI()
7
 
 
 
 
 
 
 
 
 
8
  # In-memory storage for now
9
  bus_locations: Dict[str, dict] = {}
10
 
 
2
  from pydantic import BaseModel
3
  from typing import Dict
4
  import time
5
+ from fastapi.middleware.cors import CORSMiddleware
6
 
 
7
 
8
+ app = FastAPI()
9
+ app.add_middleware(
10
+ CORSMiddleware,
11
+ allow_origins=["*"], # or set this to your frontend's origin
12
+ allow_credentials=True,
13
+ allow_methods=["*"],
14
+ allow_headers=["*"],
15
+ )
16
  # In-memory storage for now
17
  bus_locations: Dict[str, dict] = {}
18