Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the Cross-domain problem by html

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report