Update main.py
Browse files
main.py
CHANGED
|
@@ -13,6 +13,18 @@ from transformers import MarianMTModel, MarianTokenizer
|
|
| 13 |
API_KEY = os.environ.get("API_KEY")
|
| 14 |
|
| 15 |
app = FastAPI()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
api_key_header = APIKeyHeader(name="api_key", auto_error=False)
|
| 17 |
|
| 18 |
def get_api_key(api_key: Optional[str] = Depends(api_key_header)):
|
|
|
|
| 13 |
API_KEY = os.environ.get("API_KEY")
|
| 14 |
|
| 15 |
app = FastAPI()
|
| 16 |
+
# CORS issue write below code
|
| 17 |
+
origins = [
|
| 18 |
+
"http://localhost:3000", # Update this with the actual origin of your frontend
|
| 19 |
+
]
|
| 20 |
+
app.add_middleware(
|
| 21 |
+
CORSMiddleware,
|
| 22 |
+
allow_origins=origins,
|
| 23 |
+
allow_credentials=True,
|
| 24 |
+
allow_methods=["*"],
|
| 25 |
+
allow_headers=["*"],
|
| 26 |
+
)
|
| 27 |
+
# ==========================
|
| 28 |
api_key_header = APIKeyHeader(name="api_key", auto_error=False)
|
| 29 |
|
| 30 |
def get_api_key(api_key: Optional[str] = Depends(api_key_header)):
|