Postman:could not send request

Viewed 1519

I got this error from Postman: Could not send request. CORS Error: The request has been blocked because of the CORS policy.

my code is as simple as:

app.get('/',(req,res) => {
  res.send('Hi')
});

It works fine on terminal but gets err from postman, does anyone know how to solve it??

1 Answers

Just figure it out from other post.

Install the npm package "cors", require and apply it:

const cors = require("cors");
app.use(cors()); 
Related