Support Questions

Find answers, ask questions, and share your expertise

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

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>

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

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...

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