unjs / httpxy

🔀 A Full-Featured HTTP and WebSocket Proxy for Node.js
Other
194 stars 12 forks source link

WTF? I encountered a problem and asked for a solution. Did you close my issue? #42

Closed allmors closed 8 months ago

allmors commented 8 months ago

Environment

Reproduction

Use the official tutorial

Describe the bug

Describe the change

import { createServer } from "node:http";

import { createProxyServer } from "httpxy";

const proxy = createProxyServer({});

const server = createServer(async (req, res) => {
  try {
    await proxy.web(req, res, {
      target: main.url,
    });
  } catch (error) {
    console.error(error);
    res.statusCode = 500;
    res.end("Proxy error: " + error.toString());
  }
});

server.listen(3000, () => {
  console.log("Proxy is listening on http://localhost:3000");
});

The above code runs with an error image image

URLs

No response

Additional information

Additional context

No response

Logs

No response

pi0 commented 8 months ago
  1. Learn how to communicate in OSS. Even if it is a bug or lack of docs, you need to write your request properly and do your own investigation first.
  2. Learn about how HTTP and TLS works. You need proper host / headers for proxy to certain hosts
  3. Look at the error it tells you something
  4. Chat gpt is also your friend
  5. If you continue this attitude you will also get banned from this community. Again we are here to collaborate not free support and spend time for someone rude. In fact I already took time to write all these to you.