node.js CORS package suddenly stopped working

  angular, api, cors, node.js

Right not i’m working on MEAN stack application.

On the API project i am using CORS plugin with following options

const corsWhitelist = [

const corsOptions: any = {
  origin: function (origin: string, callback: any) {
    switch (process.env.ENV_MODE) {
      case EnvironmentMode.test:
        callback(null, true);
        if (corsWhitelist.indexOf(origin) !== -1) {
          callback(null, true);
        } else {
          callback(new Error("Not allowed by CORS"));
  credentials: true,
  methods: ["GET", "POST", "PATCH", "DELETE"],


The thing is, it was working fine until yesterday. I was able to make request from angular app and postman. I didn’t changed any code in API project, was just modifying angular app.

Now my front end app throws following error
but postman still works fine

Then i tried to rollback my both angular and api projects to 3 days ago (when everything was fine), but this problem didn’t gone. I think there is something happened with CORS package itself or it’s dependencies.

What can you suggest?

Source: Angular Questions

One Reply to “node.js CORS package suddenly stopped working”

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.