v3ucn / live2d-TTS-LLM-GPT-SoVITS-Vtuber

低成本的简单基于live2d TTS文字转语音和大模型聊天的直播解决方案
87 stars 15 forks source link

how to deal with CORS policy violation #3

Open a21211 opened 3 weeks ago

a21211 commented 3 weeks ago

Access to fetch at 'http://ip1:11434/api/chat' from origin 'http://ip2:3000' has been blocked by CORS policy: The request client is not a secure context and the resource is in more-private address space private. llm:466

how to deal with Cors ?

v3ucn commented 3 weeks ago

just use CORSMiddleware

app.add_middleware(
    CORSMiddleware, 
    allow_origins=origins,  #设置允许的origins来源
    allow_credentials=True,
    allow_methods=["*"],  # 设置允许跨域的http方法,比如 get、post、put等。
    allow_headers=["*"])  #允许跨域的headers,可以用来鉴别来源等作用。