我们正在尝试从 Angular 应用程序调用 mule 服务并收到 CORS 错误。
当我们在 global.xml 的 http 配置中添加 CORS 拦截器时,我们的项目遇到了问题。
<http:listener-config name="api-httpListenerConfig">
<http:listener-connection host="${http.host}" port="${http.private.port}" />
<http:listener-interceptors>
<http:cors-interceptor allowCredentials="true">
<http:origins>
<http:origin url="*" accessControlMaxAge="0">
<http:allowed-methods>
<http:method methodName="GET" />
<http:method methodName="POST" />
<http:method methodName="DELETE" />
<http:method methodName="OPTIONS" />
<http:method methodName="HEAD" />
<http:method methodName="PUT" />
</http:allowed-methods>
<http:allowed-headers>
<http:header headerName="X-Allow-Origin" />
</http:allowed-headers>
</http:origin>
</http:origins>
</http:cors-interceptor>
</http:listener-interceptors>
</http:listener-config>
GET 服务不应被浏览器中的 CORS 策略阻止。