Access-Control-Expose-Headers
响应首部 Access-Control-Expose-Headers
列出了哪些首部可以作为响应的一部分暴露给外部。
默认情况下,只有七种 simple response headers (简单响应首部)可以暴露给外部:
如果想要让客户端可以访问到其他的首部信息,可以将它们在 Access-Control-Expose-Headers
里面列出来。
Header type | Response header |
---|---|
Forbidden header name | no |
语法
Access-Control-Expose-Headers: <header-name>, <header-name>, ...
指令
- <header-name>
- 包含0个或多个除 simple response headers (简单响应首部)之外的首部名称列表,可以暴露给外部,供页面资源使用。
示例
想要暴露一个非简单响应首部,可以这样指定:
Access-Control-Expose-Headers: Content-Length
想要额外暴露自定义的首部,例如 X-Kuma-Revision
,可以指定多个,用逗号隔开:
Access-Control-Expose-Headers: Content-Length, X-Kuma-Revision
规范
Specification | Status | Comment |
---|---|---|
Fetch Access-Control-Expose-Headers |
Living Standard |
浏览器兼容性
BCD tables only load in the browser
The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
关于兼容性的注意事项
- 在最新规范中提出的通配符(*),尚未被如下浏览器实现:
- Chromium: Issue 615313
- Firefox: bug 1309358
- Servo: Issue 13283