Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

CORS error when trying to import template

CORS error when trying to import template

New Contributor

I have a docker nifi image and am trying to follow you cdc blog post:

https://community.hortonworks.com/articles/113941/change-data-capture-cdc-with-apache-nifi-version-1...

However when i try and import the downloaded template from my laptop I get a pop up box with the error:

Invalid CORS request

What do i need to do to enable CORS requests?

Can i upload templates from my local machine or do i have to upload templates from trusted URL's?

After some digging i found this implemented feature:

https://issues.apache.org/jira/browse/NIFI-5595

and the code:

https://github.com/apache/nifi/blob/master/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nif...

Regards

3 REPLIES 3

Re: CORS error when trying to import template

New Contributor

It looks like this is related to the web server.

I noticed that there are not many jetty related properties that are exposed in nifi.

Do i need to configure this through Jetty?

https://www.eclipse.org/jetty/documentation/9.4.x/cross-origin-filter.html

<web-app>

<filter>

<filter-name>cross-origin</filter-name>

<filter-class>org.eclipse.jetty.servlets.CrossOriginFilter</filter-class>

</filter>

<filter-mapping>

<filter-name>cross-origin</filter-name>

<url-pattern>*</url-pattern>

</filter-mapping>

<web-app>

Re: CORS error when trying to import template

New Contributor
Looks like this is a web server issue and i need to configure Jetty.

It doesn't look like there are many jetty properties exposed in nifi.properties, so do i need to do this through Jetty itself?

<web-app>
 <filter>
   <filter-name>cross-origin</filter-name>
   <filter-class>org.eclipse.jetty.servlets.CrossOriginFilter</filter-class>;
   <init-param>
       <param-name>allowedOrigins</param-name>
       <param-value>*</param-value>
   </init-param>
   <init-param>
       <param-name>allowedMethods</param-name>
       <param-value>*</param-value>
   </init-param>
   <init-param>
       <param-name>allowedHeaders</param-name>
       <param-value>*</param-value>
   </init-param>
 </filter>
 <filter-mapping>
     <filter-name>cross-origin</filter-name>
     <url-pattern>/*</url-pattern>
 </filter-mapping>
</web-app>

https://www.eclipse.org/jetty/documentation/9.4.x/cross-origin-filter.html

Re: CORS error when trying to import template

New Contributor

After digging further i found this post which looks like it implemented the CORS restriction for remote requests.

https://issues.apache.org/jira/browse/NIFI-5595

and here is the code behind it

https://github.com/apache/nifi/blob/master/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nif...