Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【前端成长之路】什么是跨域 #13

Open
AmamiyaCx opened this issue Sep 4, 2022 · 0 comments
Open

【前端成长之路】什么是跨域 #13

AmamiyaCx opened this issue Sep 4, 2022 · 0 comments

Comments

@AmamiyaCx
Copy link
Owner

什么是跨域

由于浏览器的同源策略影响,当请求源与请求地址存在协议、域名、端口有任何一个不同时,就会引起跨域

注意:跨域是浏览器引起的

例如:

请求源 请求地址 是否跨域
http://localhost:3000 http://localhost:3001 是,端口不同
https://www.baidu.a.com https://www.baidu.b.com 是,域名不同
http://localhost:3000 https://localhost:3000 是,协议不同
http://localhost:3000 http://localhost:3000/api

怎么解决跨域

  • JSONP
  • Nginx代理
  • CORS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant