How to solve the cross-domain problem between api server and front-end server?

  node.js, question

The browser requests static resources of the front-end server, HTML, CSS, etc.
Then the browser makes ajax requests to the api server, resulting in cross-domain problems.

The plan I’m thinking about right now,
One is to put the front and back resources under the same domain name, but the feeling is not very reasonable.
The second is to use reverse proxy, but it is not clear whether it is appropriate.

Can you tell me how to solve this problem through the back end?

There are basically the following solutions across domains

  1. JSONP

  2. CORS


  4. document.domain

  5. 5.location.hash

  6. 6.window.postMessage()

For details, please refer to the following articles …