Skip to content

Commit

Permalink
feat: enable cors to allow play video through mounted videos url
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin.zhang committed Apr 9, 2024
1 parent 6a9fe08 commit 3b1871d
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions app/asgi.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
"""Application implementation - ASGI."""
import os

from fastapi import FastAPI, Request
from fastapi.exceptions import RequestValidationError
from fastapi.responses import JSONResponse
from loguru import logger
from fastapi.staticfiles import StaticFiles
from fastapi.middleware.cors import CORSMiddleware

from app.config import config
from app.models.exception import HttpException
Expand Down Expand Up @@ -47,6 +49,17 @@ def get_application() -> FastAPI:

app = get_application()

# Configures the CORS middleware for the FastAPI app
cors_allowed_origins_str = os.getenv("CORS_ALLOWED_ORIGINS", "")
origins = cors_allowed_origins_str.split(",") if cors_allowed_origins_str else ["*"]
app.add_middleware(
CORSMiddleware,
allow_origins=origins,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)

task_dir = utils.task_dir()
app.mount("/tasks", StaticFiles(directory=task_dir, html=True, follow_symlink=True), name="")

Expand Down

0 comments on commit 3b1871d

Please sign in to comment.