Reputation: 23
We are trying to call the mule service from angular app and getting a CORS error.
Our project is having issues when we added the CORS interceptor in http config in global.xml.
<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 service should not be blocked by CORS policy in browser.
Upvotes: 0
Views: 2236
Reputation: 326
API manager lets you keep gateway logic (CORS negotiation, authentication/authorization, traffic management etc. ) out of your Mule application. But if this is an internal app and does not really benefit with an API gateway, here is one way to handle CORS in the Mule application:
The interceptor may be intended for the same purpose but trying it was unfruitful.
Upvotes: 2