fix: sse headers and extract module

This commit is contained in:
archer
2023-07-30 12:26:21 +08:00
parent b472127d3b
commit 5f5d439f55
10 changed files with 112 additions and 51 deletions

View File

@@ -113,6 +113,12 @@ export default withNextCors(async function handler(req: NextApiRequest, res: Nex
throw new Error('Question is empty');
}
// 创建响应流
res.setHeader('Content-Type', 'text/event-stream;charset=utf-8');
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('X-Accel-Buffering', 'no');
res.setHeader('Cache-Control', 'no-cache, no-transform');
/* start process */
const { responseData, answerText } = await dispatchModules({
res,