Skip to content

Commit

Permalink
Add CORS middleware, all origins
Browse files Browse the repository at this point in the history
  • Loading branch information
braddf committed Feb 14, 2024
1 parent 1be7bf7 commit b98c37e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/india_api/internal/service/server.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
"""Defines the routes of the API."""

import os
import datetime as dt
import pytz
import logging
from typing import Annotated

from fastapi import Depends, FastAPI, HTTPException, status
from fastapi.middleware.cors import CORSMiddleware
from pydantic import BaseModel

from india_api.internal import (
Expand All @@ -25,6 +27,14 @@
title="India API",
description="API providing OCF Forecast for India",
)
origins = os.getenv("ORIGINS", "*").split(",")
server.add_middleware(
CORSMiddleware,
allow_origins=origins,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)


def get_db_client() -> DatabaseInterface:
Expand Down

0 comments on commit b98c37e

Please sign in to comment.