Skip to content

Commit 3db8bb1

Browse files
authored
fix(fake-api/vite): status code (#5128)
I've noticed that when setting a `Status-Code` header in the mocks, it's not properly passed through the vite middleware. --------- Signed-off-by: schogges <moritz.fleck@konghq.com>
1 parent d8f3596 commit 3db8bb1

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

packages/fake-api/src/vite.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,10 @@ export default <TDependencies extends object = {}>(opts: PluginOptions<TDependen
5252
headers,
5353
})
5454
const type = response.headers.get('Content-Type') ?? 'application/json'
55+
const statusCode = response.headers.get('Status-Code') ?? '200'
5556
res.setHeader('Content-Type', type)
56-
res.setHeader('Status-Code', response.headers.get('Status-Code') ?? '200')
57+
res.setHeader('Status-Code', statusCode)
58+
res.statusCode = parseInt(statusCode)
5759
const resp = type.endsWith('/json') ? JSON.stringify((await response.json()), null, 4) : (await response.text())
5860

5961
const cookies = Cookie.parse(req.headers?.cookie ?? '', { prefix: 'KUMA_' })

0 commit comments

Comments
 (0)