For example, on the same server, the main directory of the website is bound to www.domain.com, and the backend of the website is bound to www.domain.com:8080.
Even if the ports are different, it will be regarded as cross-domain, right? I feel that this situation is a bit unfair across domains, and POST is not cross-domain convenient, right?
Do you have any good ways to solve this problem? Can you use certain settings to prevent cross-domain between the website and the backend? This method of separating the website and the backend will face cross-domain problems sooner or later, right?
There are many cross-site solutions, the common ones are JSONP, proxy forwarding, and the new feature of HTLM5's Allow Origin that allows cross-site access.
In your case, it is recommended to set up a proxy in Ngingx of the website and forward it to the website backend. The configuration is probably like this:
On the front-end page, the address accessed through ajax is: http://www.example.com/api/xxx
Different ports are inherently different sites, and sites are cross-domain! By separating the front-end and back-end, the website can be more secure and can be maintained separately. I don’t think it is necessary to use the front-end to cross-domain requests to the back-end. This will expose the back-end, and the program design should not retrieve data across domains through the front-end. Bar! Unless your database is a file database such as Access or SQLite, then it is a design problem. Requesting data only requires a data connection. No need to cross domains.