Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: connect ECONNREFUSED 127.0.0.1:80 #1

Open
slutske22 opened this issue Dec 7, 2020 · 0 comments
Open

Error: connect ECONNREFUSED 127.0.0.1:80 #1

slutske22 opened this issue Dec 7, 2020 · 0 comments

Comments

@slutske22
Copy link

I am trying to use your middleware. When I start my server and go to localhost:3000/cors-anywhere, I would expect to see the cors-anywhere text, but I get this:

Error: connect ECONNREFUSED 127.0.0.1:80
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1056:14)

My code is simply:

import express from 'express';
import cors from 'cors';
import anywhere from 'express-cors-anywhere';
import path from 'path';

const { PORT } = process.env;
const port = PORT || 3030;

var app = express();

app.use(cors());
app.use('/cors-anywhere', anywhere());

app.get('*', (req, res) => {
	console.log('gotten');
	res.sendFile(path.resolve(__dirname, 'index.html'));
});

app.listen(port, () => {
	console.log(`App listening on port ${port}`);
});

I get the same error when I use the example code from your readme:

import express from "express";
import axios from "axios";
import { json } from "body-parser";
import anywhere from "express-cors-anywhere";

const { PORT } = process.env;
const port = PORT || 3000;

(async () => {
  /* configure cors */
  await new Promise(
    resolve => express()
      .use(json())
      .use("/cors-anywhere", anywhere())
      .get("/hello", (_, res) => res.status(200).send("Hi!"))
      .listen(port, resolve),
  );
})();

Is this error expected?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant