Support Questions

Find answers, ask questions, and share your expertise
Check out our newest addition to the community, the Cloudera Data Analytics (CDA) group hub.

CORS header 'Access-Control-Allow-Origin' missing exception invoking NiFi flow rest endpoint.

I have NiFi flow exposed as REST endpoint using ListenHTTP processor. I am able to access the REST endpoint using java client with no issues but when I tried accessing the same endpoint using web application (html/javascript) I am getting following exception.

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at <REST end point>. (Reason: CORS header 'Access-Control-Allow-Origin' missing).


I am able to resolved this by using XMLHttpRequest object event handlers on the client side application.

View solution in original post


I am able to resolved this by using XMLHttpRequest object event handlers on the client side application.

New Contributor

Hello Milind,

I have run into the same issue and I do not see way how to set 'Access-Control-Allow-Origin' header in ListenHTTP processor.

"Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://XXX' is therefore not allowed access." Could you please share more details how you solved it? Thanks,


New Contributor

I managed to solve it with jQuery like this:

    url: url,
    type: "POST",
    crossDomain: true,
    data: data,
    dataType: "json",

New Contributor

The previous was not quite correct - still some errors in browser. Finally I solved it using handleHttpRequest and handleHttpResponse porocessor the latter one returning custom header (aka custom property)access-control-allow-origin:*

New Contributor

Hi All, Please let me know validation checkpoints to do this. Still not able to figure out .

New Contributor

I'm glad you were able to find a workaround. But if I understand the solution correctly, then we must use JQuery and abandon hopes of using the Fetch API? I would like to use CORS for the added security and feel like this is not a holistic solution. The root issue seems to be that NiFi admins cannot add origins. Is this really the only option?

New Contributor
Hi All, I allowed access via custom attribute in httpresponse but still having CORS Policy issue, Please let me know what all checks are required to validate it .

New Contributor



I added the following on the handle response processor:


Access-Control-Allow-Headers: Content-Type

Access-Control-Allow-Methods: POST

Access-Control-Allow-Origin: *


I also had to allow the options method in the handle http request processor and respond to the options request with this header. You could use wildcards for everything if you are testing.


The browser does a preflight options request for cross origin requests. It does this if it is not classified as a simple request:


So if you set the content-type to application/json on the client for a cross origin post the browser will check if the server supports it with the options request.

Take a Tour of the Community
Don't have an account?
Your experience may be limited. Sign in to explore more.