You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

9 lines
685 B
Markdown

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# CORS(跨域资源共享)学习项目
## 原理
![原理](Assets/CORS原理.png)
> 客户端:浏览器请求时,请求头携带上 Origin 标签(只包含请求站点信息,不包含路径信息。比如 http://localhost:5002),一般由浏览器或请求程序自动判断是否跨域而自动设置,无需人工参与,但是为了方便测试等,也可以强制添加。
> 服务端 asp.net core 设置CORS后如果请求头携带有 Origin 标签则在响应头中添加CORS标签明确浏览器可以跨域。
## 坑一服务端设置好Cors后直接访问、Swagger、PostMan等工具测试时响应头中并不返回 Cors相关标头。