js cross domain and solution

1. What is spanning?

A webpage requests resources from another webpage with a different domain name/different protocol/different port, which is cross-domain.

2. What is the reason for cross-domain?

In the current domain name request website, sending other domain names through ajax request is not allowed by default.

3. Why is there a cross-domain request?

Because the browser uses the same-origin policy

4. What is the same-origin policy?

The protocol, domain name, and port number must be exactly the same. Violation of the same-origin policy is cross-domain.

5. Why do browsers use the same-origin policy?

It is to ensure the user's information security and prevent malicious websites from stealing data

6. Five cross-domain solutions

  • Frontend uses jsonp (deprecated)
  • Background Http request forwarding
  • Configure same-origin Cors in the background (recommended)
  • Use Spring Cloud Gateway
  • Use nginx for forwarding (recommended)

Guess you like

Origin blog.csdn.net/m0_71933813/article/details/129900564