华为云UCS-CORS

时间:2025-02-12 15:05:17

CORS

当一个资源向该资源所在服务器的不同的域发起请求时,就会产生一个跨域的HTTP请求。出于安全原因,浏览器会限制从脚本发起的跨域HTTP请求。通过跨域资源共享CORS机制可允许Web应用服务器进行跨域访问控制,使跨域数据传输安全进行。

YAML设置如下:

apiVersion: networking.istio.io/v1beta1kind: VirtualServicemetadata:  name: ratings-routespec:  hosts:  - ratings.prod.svc.cluster.local  http:  - route:    - destination:        host: ratings.prod.svc.cluster.local        subset: v1    corsPolicy:                   # 配置跨域资源共享      allowOrigins:      - exact: https://example.com      allowMethods:      - POST      - GET      allowCredentials: false      allowHeaders:      - X-Foo-Bar      maxAge: "24h"

请根据实际需求调整配置参数。

support.huaweicloud.com/usermanual-ucs/ucs_02_0033.html