Merge pull request #1754 from popcell/fix-immutable-header

fix: #1746 Can't modify immutable headers.
This commit is contained in:
Yifei Zhang 2023-05-25 18:32:30 +08:00 committed by GitHub
commit 9aea6c5585
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -50,7 +50,13 @@ export async function requestOpenai(req: NextRequest) {
if (res.status === 401) {
// to prevent browser prompt for credentials
res.headers.delete("www-authenticate");
const newHeaders = new Headers(res.headers);
newHeaders.delete("www-authenticate");
return new Response(res.body, {
status: res.status,
statusText: res.statusText,
headers: newHeaders,
});
}
return res;