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.{scene}.js

  1. 1export default {
  2. 2 api: {
  3. 3 baseURL: 'http://other.backend.com',
  4. 4 },
  5. 5};

Backend Configuration

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

src/backend/config/config.prod.js

  1. 1 // module config
  2. 2 config.modules = {
  3. 3 'a-base': {
  4. 4 cors: {
  5. 5 whiteList: 'http://some.front.com',
  6. 6 },
  7. 7 },
  8. 8 };

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