Enable CORS Into Mule 4 at Application Level

DZone 's Guide to

Enable CORS Into Mule 4 at Application Level

In this article, take a look at how to enable CORS into Mule 4 at the application level.

· Integration Zone ·
Free Resource

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 ,integration ,cors enabled ,tutorial ,enable cors ,cross origin resource sharing

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}