Skip to content

Commit

Permalink
chore: add header merge
Browse files Browse the repository at this point in the history
  • Loading branch information
darkskygit committed Jul 9, 2024
1 parent 6e68e69 commit d2b0698
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18
20
7 changes: 7 additions & 0 deletions packages/utils/src/response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,20 @@ export function respOk(
body: string | null,
options: {
allowOrigin?: string;
headers?: Record<string, string>;
} = {},
) {
const headers = new Headers();
headers.set('content-type', 'application/json;charset=UTF-8');
if (options.allowOrigin) {
headers.set('Access-Control-Allow-Origin', options.allowOrigin);
}
if (options.headers) {
for (const [key, value] of Object.entries(options.headers)) {
headers.set(key, value);
}
}

return new Response(body, {
headers,
status: 200,
Expand Down

0 comments on commit d2b0698

Please sign in to comment.