From f339a11036c0b1efb0fd1d3d870e6833b2c4e0be Mon Sep 17 00:00:00 2001 From: Daniel Gatis Date: Fri, 29 Apr 2022 11:54:09 -0300 Subject: [PATCH] allow all cors --- rembg/cli.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/rembg/cli.py b/rembg/cli.py index 6e8c5bc5..10f41b17 100644 --- a/rembg/cli.py +++ b/rembg/cli.py @@ -10,6 +10,7 @@ import uvicorn from asyncer import asyncify from fastapi import Depends, FastAPI, File, Query +from fastapi.middleware.cors import CORSMiddleware from starlette.responses import Response from tqdm import tqdm from watchdog.events import FileSystemEvent, FileSystemEventHandler @@ -270,6 +271,14 @@ def s(port: int, log_level: str) -> None: openapi_tags=tags_metadata, ) + app.add_middleware( + CORSMiddleware, + allow_credentials=True, + allow_origins=["*"], + allow_methods=["*"], + allow_headers=["*"], + ) + class ModelType(str, Enum): u2net = "u2net" u2netp = "u2netp"