Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

717
Views
Trying to make a GET request from localhost:8080 to localhost:3000 but I get a cors error, and installing cors on my node.js server doesn't fix it

So I'm trying to make an axios GET request to my Node.js/Express.js localhost:3000 server from my front-end app on localhost:8080 and I understand why I am getting a CORS error. What I don't understand is why after I installed the cors npm package and used it as middleware on my Node.js/Express.js back-end, I still get the CORS error.

I did this inside the app.js file

var cors = require('cors');
app.use(cors());

Then I still get the following error when I try to make a GET request from my front-end:



Access to XMLHttpRequest at 'http://localhost:3000/images' from origin 'http://localhost:8080' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Shouldn't me using the cors package solve this problem?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You have to allow cors to receive that origin. There's a good good video about this. But adding the parameter origin to the cors() middleware should solve it.

var cors = require('cors');
app.use(cors({
    origin: "http://localhost:8000"
}));
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!