Use KHOJ_DOMAIN for CORS allow_origins list as well

- Default to app.khoj.dev
- Remove unnecesary any_path regex in allow_origins. It only cares
  about host, paths are not set in origin header
This commit is contained in:
Debanjum Singh Solanky
2023-11-21 14:02:04 -08:00
parent 76d041f633
commit 9e736d4340

View File

@@ -51,9 +51,16 @@ app = FastAPI()
django_app = get_asgi_application()
# Add CORS middleware
KHOJ_DOMAIN = os.getenv("KHOJ_DOMAIN", "app.khoj.dev")
app.add_middleware(
CORSMiddleware,
allow_origins=["app://obsidian.md", "http://localhost:*", "https://app.khoj.dev/*", "app://khoj.dev"],
allow_origins=[
"app://obsidian.md",
"http://localhost:*",
"http://127.0.0.1:*",
f"https://{KHOJ_DOMAIN}",
"app://khoj.dev",
],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],