Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
450 views
in Technique[技术] by (71.8m points)

关于cors跨域的时候,请求头中带cookie的问题?

对于cors跨域我也不是很清楚。是不是就是我的页面访问我自己的服务器,然后自己的服务器访问目标服务器请求资源?

那要是目标服务器请求资源需要带cookie的话要怎么带cookie呢?

是否可以在自己的服务器上的请求中带cookie呢?

用的axios访问,如下图
image.png

这种在线接口测试工具的原理是啥呢?(比如跨域,填入cookie)

image.png


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
  1. 网站是 a.com,请求地址不是 a.com,比如 b.com,或者 api.a.com,那么就是跨域
  2. 跨域时,如果目标服务器返回了跨域头,那么大概率可以访问
  3. 你访问自己的服务器,再用服务器访问目标服务器,这叫代理
  4. 代理的 cookie 规则根据你的代理服务器来定

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...