请求首部字段 Origin 指示了请求来自于哪个站点。该字段仅指示服务器名称,并不包含任何路径信息。该首部用于 CORS 请求或者 POST 请求。除了不包含路径信息,该字段与 Referer 首部字段相似。
| Header type | Request header |
|---|---|
| Forbidden header name | yes |
语法
Origin: "" Origin: <scheme> "://" <host> [ ":" <port> ]
有时候将该字段的值置空是有用的,例如,资源由一个 data URL 指定。
声明
- <scheme>
- 请求所使用的协议,一般是 HTTPS 协议。
- <host>
- 目的域名或 IP 地址。
- <port> 可选
- 目的 TCP 端口。缺省为服务的默认端口(对于 HTTP 请求而言,默认端口为 80)。
示例
Origin: https://developer.mozilla.org
规范
| Specification | Comment |
|---|---|
| RFC 6454, section 7: Origin | The Web Origin Concept |
| Fetch Origin header |
Supplants the Origin header as defined in RFC6454. |
浏览器兼容性
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.
| Feature | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | Servo |
|---|---|---|---|---|---|---|---|
| Origin | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) |
| Feature | Android | Chrome for Android | Edge Mobile | Firefox for Android | IE Mobile | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|---|---|
| Origin | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) |