From a556aeb7e8aa3e4ea449df72e3e233afec1ccf39 Mon Sep 17 00:00:00 2001 From: KITAHARA SETSUNA Date: Sun, 25 Aug 2024 19:32:14 +0900 Subject: [PATCH] fix: do CORS only when opt.cors is true --- packages/vite-plugin-mock/src/createMockServer.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/vite-plugin-mock/src/createMockServer.ts b/packages/vite-plugin-mock/src/createMockServer.ts index c092734..c27b4d0 100644 --- a/packages/vite-plugin-mock/src/createMockServer.ts +++ b/packages/vite-plugin-mock/src/createMockServer.ts @@ -88,8 +88,8 @@ export async function requestMiddleware(opt: ViteMockOptions) { } else { const body = await parseJson(req) res.setHeader('Content-Type', 'application/json') - if (opt) { - res.setHeader('Access-Control-Allow-Credentials', true) + if (opt.cors) { + res.setHeader('Access-Control-Allow-Credentials', 'true') res.setHeader('Access-Control-Allow-Origin', req.headers.origin || '*') } res.statusCode = statusCode || 200