I have been working on Nuxt2 for a while, and so I thought I would give 3 a try. After I finish the installation instructions found here: https://nuxt.com/docs/getting-started/installation I am getting the following error when I run a local server:
ERROR [uncaughtException] proxyReq.appendHeader is not a function
.
It appears to be related to the nitro engine that Nuxt is using:
at ProxyServer.<anonymous> (/C:/Users/cards/Documents/job-hunt/job-site/node_modules/nitropack/dist/chunks/server.mjs:329:18)
at ProxyServer.emit (node:events:527:28)
at ClientRequest.<anonymous> (/C:/Users/cards/Documents/job-hunt/job-site/node_modules/httpxy/dist/index.mjs:256:16)
at ClientRequest.emit (node:events:527:28)
at tickOnSocket (node:_http_client:764:7)
at onSocketNT (node:_http_client:827:5)
at process.processTicksAndRejections (node:internal/process/task_queues:83:21)
我希望,如果我做了任何改变,我本可以打破某些错误,但这些错误从一开始就是正确的。 我做了一些研究,没有发现与此类似的问题。
守则中引起我争议的部分是:
proxy.proxy.on("proxyReq", (proxyReq, req) => {
if (!proxyReq.hasHeader("x-forwarded-for")) {
const address = req.socket.remoteAddress;
if (address) {
proxyReq.appendHeader("x-forwarded-for", address);
}
}
if (!proxyReq.hasHeader("x-forwarded-port")) {
const localPort = req?.socket?.localPort;
if (localPort) {
proxyReq.setHeader("x-forwarded-port", req.socket.localPort);
}
}
if (!proxyReq.hasHeader("x-forwarded-Proto")) {
const encrypted = req?.connection?.encrypted;
proxyReq.setHeader("x-forwarded-proto", encrypted ? "https" : "http");
}
});
带有错误的准确行数 : proxyReq. append header ("x- toward- for", 地址);
我使用的是Nuxt版本:3.10.3和氮2.9.1。