Latest News

Enable CORS Into Mule 4 at Application Level

Mule standing in paddock

Cross-origin resource sharing (CORS) is a mechanism that allows restricted resources on a web page to be requested from another domain outside the domain from which the first resource was served.

There are some situations when we need to enable CORS at the Mule application side so that UI applications like React JS and Angular JS can integrate exposed APIs. Below is the procedure of how we can enable CORS into a Mule 4 application-level at the HTTP listener level.

There are two ways we can allow CORS at Mule 4 application level.

1. Add Origin

You might also like: 
Do You Really Know CORS?

“Add Origin” will be used to add a specific URL. Below parameters, we can add “Add Origin.”

  • Origin URL
  • Access Control Max Age
  • Allowed Methods
  • Allowed HTTP Request Headers

2. Add Public Resource

Under “Add Public resource,” we are allowing all public URLs.

The XML for “Add public resource” is shown below.

Thanks, and happy coding.

Further Reading

Basics of CORS (Cross-Origin Resource Sharing)

CORS (Cross-Origin Request Sharing) in Mule


mule 4
cors enabled
enable cors
cross origin resource sharing

Opinions expressed by DZone contributors are their own.

Read More

Show More

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button

Adblock Detected

Please consider supporting us by disabling your ad blocker