Skip to content

Commit ca3a8c3

Browse files
authored
Merge pull request #59 from mrhan1993/main
Add CORS support.
2 parents 5b0d609 + ac1bad7 commit ca3a8c3

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

fooocusapi/api.py

+10
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,19 @@
1010
from fooocusapi.task_queue import TaskType
1111
from fooocusapi.worker import process_generate, task_queue, process_top
1212
from concurrent.futures import ThreadPoolExecutor
13+
from fastapi.middleware.cors import CORSMiddleware
14+
1315

1416
app = FastAPI()
1517

18+
app.add_middleware(
19+
CORSMiddleware,
20+
allow_origins=["*"], # 允许所有来源访问
21+
allow_credentials=True,
22+
allow_methods=["*"], # 允许所有HTTP方法
23+
allow_headers=["*"], # 允许所有请求头
24+
)
25+
1626
work_executor = ThreadPoolExecutor(
1727
max_workers=task_queue.queue_size*2, thread_name_prefix="worker_")
1828

0 commit comments

Comments
 (0)