From 58e2cf78e6df6ad944d775e06d03657b8ec01a8f Mon Sep 17 00:00:00 2001 From: Azalea <22280294+hykilpikonna@users.noreply.github.com> Date: Sat, 13 Jul 2024 04:23:20 +0800 Subject: [PATCH] [O] Allow CORS --- api.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/api.py b/api.py index 95f90b9..fe64407 100644 --- a/api.py +++ b/api.py @@ -11,6 +11,7 @@ import uvicorn from fastapi import FastAPI, HTTPException, Request from fastapi.responses import StreamingResponse from hypy_utils.logging_utils import setup_logger +from starlette.middleware.cors import CORSMiddleware from torch import no_grad, LongTensor import commons @@ -31,6 +32,15 @@ language_marks = { "Mix": "", } +# Allow all CORS +app.add_middleware( + CORSMiddleware, + allow_origins=["*"], + allow_credentials=True, + allow_methods=["*"], + allow_headers=["*"], +) + def get_text(text: str, is_symbol: bool): text_norm = text_to_sequence(text, hps.symbols, [] if is_symbol else hps.data.text_cleaners)