How to solve the Cross-domain problem by html
This article mainly introduces html how to solve cross-domain problems, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.
Cross-domain
Browser homology policy was introduced into browsers by Netscape in 1995. Currently, all browsers implement
This policy. At first, it means that the Cookie,B page set up by the A page cannot be opened unless the two networks
Page "homologous". The so-called "homology" refers to "three identical".
Same http https domain name same www.xdclass.net port same 8081 sentence: when the browser requests the resources of another domain name from the web page of one domain name, the domain name, port and protocol are all different, it is the cross-domain prompt of the cross-domain browser console: No 'Access-Control-Allow-Origin' header is present on the requested resource.Origin' null' is therefore not allowed access. Solution method
JSONP
This layer of the page is packaged with another layer of service. At present, it is nodejs at most.
Http response header configuration allows cross-domain
Nginx proxy server
Back-end program code configuration
In the program code, SpringBoot accepts requests for any domain name through interceptor configuration / /. You can also specify the domain name response.setHeader ("Access-Control-Allow-Origin", request.getHeader ("origin")); / / this field is optional and is a Boolean value, indicating whether cookieresponse.setHeader ("Access-Control-Allow-Credentials", "true") can be carried. Response.setHeader ("Access-Control-Allow-Methods", "GET, HEAD, POST,PUT, PATCH, DELETE, OPTIONS"); response.setHeader ("Access-Control-Allow-Headers", "*"); Thank you for reading this article carefully. I hope the article "how to solve Cross-domain problems in html" shared by the editor will be helpful to you. At the same time, I hope you will support us, pay attention to the industry information channel, and more related knowledge is waiting for you to learn!