【发布时间】:2016-05-11 18:57:15
【问题描述】:
我正在使用带有 APIKit + RAML 的 Mule 3.7。缺乏关于 mule 的 http 响应构建器等的文档。
Http Credentials 不适用于 Access-Control-Allow-Origin 的通配符,因此需要删除通配符,并将值动态设置为消息头中的来源。
错误: 当凭证标志为真时,不能在“Access-Control-Allow-Origin”标头中使用通配符“*”。 Origin 'http://localhost:8080' 因此不允许访问。
如何将 Access-Control-Allow-Origin 值设置为 #[message.inboundProperties['origin']]
<flow name="api-main">
<http:listener config-ref="api-httpListenerConfig" path="/api/*" doc:name="HTTP">
<http:response-builder>
<http:header headerName="Access-Control-Allow-Origin" value="*"/>
</http:response-builder>
</http:listener>
<apikit:router config-ref="api-main-config" doc:name="APIkit Router"/>
<exception-strategy ref="component-registry-apiKitGlobalExceptionMapping" doc:name="Reference Exception Strategy"/>
</flow>
【问题讨论】:
-
您好,抱歉,我不确定您的要求。您想在对 API 的 http 请求中覆盖标头 Access-Control-Allow-Origin 以覆盖客户端发送的内容,或者您希望在响应客户端时覆盖标头,以便在响应中?
-
在响应客户端时覆盖标题。
-
这个问题应该不是mule版本特有的,好像问题和解决方案可以适用于新版本