Ich navigiere in meinem Browser zu „localhost:5000“
Es führt mich zu https://www.reddit. com, Seite sieht durcheinander aus und nur HTML wird gerendert
Ich öffne die Browserkonsole, jede Menge Fehler über Axios (Reddit-API wird verwirrt?)
Dies ist der relevante Code:
Code: Select all
const url = 'https://www.reddit.com/';
const proxyAgent = new HttpsProxyAgent(
`https://${proxy_username}:${proxy_password}@${proxy_host}:${proxy_port}`,
);
const proxyMiddleware = createProxyMiddleware({
cookieDomainRewrite: {
'*': '',
},
target: url,
changeOrigin: true,
ws: true,
agent: proxyAgent,
autoRewrite: true,
pathRewrite: {
'^/': '/',
},
on: {
proxyRes: function (
proxyRes: http.IncomingMessage,
req: http.IncomingMessage,
res: http.ServerResponse,
) {
proxyRes.headers['Access-Control-Allow-Origin'] = '*';
proxyRes.headers['Access-Control-Allow-Credentials'] = 'true';
proxyRes.headers['Content-Security-Policy'] = 'upgrade-insecure-requests';
if (proxyRes.headers.location) {
proxyRes.headers.location = proxyRes.headers.location.replace(
url,
`http://localhost:${port}`,
);
}
},
},
});