reza
reza

Reputation: 6358

how to work around a Access-Control-Allow-Origin error

I have two node servers on localhost:3000 and localhost:4000. I call 4000 from 3000 and get the following error.

No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access.

Any suggestions for this error?

Upvotes: 0

Views: 191

Answers (1)

Abhishek
Abhishek

Reputation: 1477

If the 4000 server is a express based node server, use "cors" package to solve it like below

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

Where app is an express application.

Upvotes: 3

Related Questions