Skip to content

Commit af97090

Browse files
Copilothotlong
andcommitted
Address code review: handle array headers and conditional content-type in NestJS adapter
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 4d6cad6 commit af97090

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

packages/adapters/nestjs/src/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,15 @@ export class ObjectStackController {
121121
if (req.headers) {
122122
Object.entries(req.headers).forEach(([k, v]) => {
123123
if (typeof v === 'string') headers.set(k, v);
124+
else if (Array.isArray(v)) headers.set(k, v.join(', '));
124125
});
125126
}
126127
const init: RequestInit = { method: req.method, headers };
127128
if (req.method !== 'GET' && req.method !== 'HEAD' && body) {
128129
init.body = JSON.stringify(body);
129-
headers.set('content-type', 'application/json');
130+
if (!headers.has('content-type')) {
131+
headers.set('content-type', 'application/json');
132+
}
130133
}
131134
const webRequest = new Request(url, init);
132135
const response = await authService.handleRequest(webRequest);

0 commit comments

Comments
 (0)