Skip to content

Commit

Permalink
Configure CORS
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-lu committed Jul 3, 2023
1 parent 017fc16 commit ceb7a35
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 3 additions & 4 deletions backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@
import newsfeed
import ai_assistant
from typing import Dict, Any
import os


models.Base.metadata.create_all(bind=engine)

# Allowed origins for avoiding CORS errors
origins = [
"http://localhost:3000"
]
allowed_origins = os.getenv("ALLOWED_ORIGINS", "http://localhost:3000")

description = "## OSINT Toolkit interactive API documentation"

Expand Down Expand Up @@ -81,7 +80,7 @@

app.add_middleware(
CORSMiddleware,
allow_origins=origins,
allow_origins=allowed_origins.split(","),
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ services:
container_name: backend
ports:
- "8000:8000"
environment:
- ALLOWED_ORIGINS=http://localhost:3000
frontend:
build: ./frontend
container_name: frontend
Expand Down

0 comments on commit ceb7a35

Please sign in to comment.