Set Cors Cross-domain
Last Updated:2020-09-17
This interface is used to specify the Cors cross-domain settings of the accelerated domain name.
Cross-domain access means that the domain in which the resource initiating the request is located is different from the domain in which the resource pointed to by the request is located. For security reasons, browsers will restrict this non-homologous access. By enabling such feature, the users can clear the cache and access the configuration cross domains, and after the object of origin server (BOS) is updated, all caches corresponding to CDN can be updated automatically and synchronously.
Note
- Connect to CORS standard supported by BOS to realize cross-domain access, and the count of Origins must not exceed 100, and the characters of header must not exceed 50.
- For specific CORS rules, please see: W3C CORS Standard.
Method | Path | Description |
---|---|---|
PUT | /v2/domain/{domain}/config?cors | Set Cors cross-domain |
Request body
Parameter | Optional | Type | Description |
---|---|---|---|
cors | Required | Json | Detailed configurations for cors |
allow | Required | String | “on” means allowing cross-domain access, and “off” means not allowing cross-domain access. |
originList | Optional | Array | It indicates the list of domain names with cross-domain allowed. It supports extensive domain names. Each url only supports one wildcard, such as “http:// *.bce.com " and does not support domain names like “http:// *. * .com/ " “. |
Request example
PUT /v2/domain/myself.baidu.com/config?cors HTTP/1.1
Host: cdn.baidubce.com
Content-Length: 72
Content-Type: text/json;utf-8
{
"cors":
{
"allow":"on",
"originList":[
"http://www.baidu.com",
"http://*.bce.com"
]
}
}
Response code (Http Status Code)
HTTP Status Code | Description |
---|---|
200 | Success |
400 | Update failures, parameter errors, etc. |
Response body
Parameter | Type | Description |
---|---|---|
status | String | The status returned after it was just updated successfully is OPERATING. |
Response example
HTTP/1.1 200 OK
Server: nginx/1.14.0
Date: Fri, 21 Sep 2018 03:46:35 GMT
Content-Type: application/json; charset=utf-8
Transfer-Encoding: chunkedConnection: keep-alive
X-Powered-By: PHP/5.6.36
x-bce-request-id: dd490e5d-64da-e2b-1cdd-fc98c864dfd
{"status":"OPERATING"}