Scenario

In some special scenarios, frontend resources and backend services are not deployed on the same machine, and different domain names are used. At this time, there will be cross domain problems when the frontend perform the backend API services

CabloyJS has built-in very convenient cors support. The specific configuration is as follows:

Frontend Configuration

Just modify the parameter api.baseURL in the frontend configuration

src/front/config/config.js

export default {
  api: {
    baseURL: 'http://other.backend.com',
  },
};

Backend Configuration

Just modify the parameter cors.whiteList of the module a-base

src/backend/config/config.prod.js

  // module config
  config.modules = {
    'a-base': {
      cors: {
        whiteList: 'http://some.front.com',
      },
    },
  };

cors.whiteList: Can be multiple domain names separated by commas