我正在尝试通过网关后面的离子iOS应用程序调用istio虚拟服务。
由于使用了webkitUIView,该应用程序需要对应用程序使用非http URL方案。
因此,该应用会以ionic://localhost
打开,从而在发出http请求时将Origin设置为相同。以下是示例网址
curl 'http://some-host/api/user/login/' \
-XPOST \
-H 'Accept: application/json, text/plain, */*' \
-H 'Content-Type: application/json' \
-H 'Origin: ionic://localhost' \
-H 'User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 13_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148' \
--data-binary '{"username":"+1231231231223","mobileNo":"+123123123123","password":""}'
但是后端是istio虚拟服务,我正在尝试找出一种设置来接受的方法
Origin
是相同的,但是它不允许ionic://localhost
,因为它假定:
之后的任何内容都是port,并且抱怨格式不正确。
http:
- corsPolicy:
allowCredentials: true
allowHeaders:
- authorization
- content-type
- accept
- origin
- user-agent
- appInfo
- referer
allowMethods:
- GET
- POST
- OPTIONS
- PUT
allowOrigin:
- 'http://localhost:8100'
- 'http://localhost'
- 'ionic://localhost'
exposeHeaders:
- x-custom-header
maxAge: 300s
match:
- uri:
prefix: /some-prefix/
route:
- destination:
host: some-host
port:
number: 7261
我得到的确切错误低于
for: "virtual-server.yaml": admission webhook "validation.istio.io" denied the request: configuration is invalid: port in CORS Allow Origin is not a number: //localhost