node.js 获取 https 无响应 504

node.js get https no responding 504

我正在尝试在我的后端 node.js 网络应用程序中发出 https 请求。我有以下代码:

const express = require('express');
const https = require('https');

const app = express();

app.get("/", function(req, res) {

  const url = "https://www.tkmaxx.com/uk/en/women/edits/big-brand-drop/c/01240000/autoLoad?page=1"
  https.get(url, function(response) {

    console.log(response.statusCode);

  });
  res.send("running test")
});

app.listen(3000, function() {
  console.log("Server started on port 3000");
});

我收到以下错误:

node:events:504
      throw er; // Unhandled 'error' event
      ^

Error: socket hang up
    at connResetException (node:internal/errors:691:14)
    at TLSSocket.socketOnEnd (node:_http_client:466:23)
    at TLSSocket.emit (node:events:538:35)
    at endReadableNT (node:internal/streams/readable:1345:12)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) 
Emitted 'error' event on ClientRequest instance at:
    at TLSSocket.socketOnEnd (node:_http_client:466:9)
    at TLSSocket.emit (node:events:538:35)
    at endReadableNT (node:internal/streams/readable:1345:12)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {   code: 'ECONNRESET' }

有人知道这是怎么回事吗?问题与请求 headers 或用户代理有关吗?我该如何设置?

仅当远程服务器具有 Accept header 和 Connection: keep-alive 时,该请求才会被远程服务器接受。 (这些是浏览器通常设置的标题。)

https.get("https://www.tkmaxx.com/uk/en/women/edits/big-brand-drop/c/01240000/autoLoad?page=1", {
  headers: {
    accept: "text/html",
    connection: "keep-alive"
  }
}, function(response) {...});

(也许这是远程服务器用来防止浏览器以外的客户端发出的请求的一种机制?)