Skip to content

Commit

Permalink
fix(request): 修复 301 重定向不包含完整域名时会失败的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
renxia committed May 21, 2024
1 parent e2952e0 commit c9ad372
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/node/lib/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ export class Request extends ReqBase {
const req: http.ClientRequest = h.request(options, res => {
globalThis.clearTimeout(timer);
if (autoRedirect && String(res.statusCode).startsWith('30') && res.headers['location']) {
this.req(res.headers['location'], parameters, options, true).then(resolve);
let rurl = res.headers['location'];
if (!rurl.startsWith('http')) rurl = (res.headers['host'] || url.host) + rurl;
this.req(rurl, parameters, options, true).then(resolve);
} else resolve({ req, res });
});

Expand Down

0 comments on commit c9ad372

Please sign in to comment.