Front-end cool development environment, access to local static resources, access to local ajaxmock or test environment API interface, switch at will

  node.js, question

In order to build a local development environment, webpack plus gelp nodejs environment, the purpose is to easily access the interface between local resources and api of test environment.

1. The address bar of the local development environment reads as follows:clipboard.png
So when the program inside sends ajax, it must start with localhost, and there will be a cross-domain situation. How to deal with it?

2: If the address bar accesses the domain name of the test environment, how can it proxy to the local static resources? The changes will take effect immediately.

Since it is local, then CORS directly, if you don’t have permission, you can try nginx Reverse proxy.