Jump to content
Changes to the Jaspersoft community edition download ×

CORS error when using jasper REST V2 API (Jasper server 7.5.1)


jeanpierrepolnareff91

Recommended Posts

Hello everyone,

I have read a usefull documentation which explains how to create a schedule job available in jasperreports server with a javascript script : 

https://community.jaspersoft.com/wiki/example-using-javascript-schedule-report-rest

When I try to use it inside my angular application, an error is triggered : 

"access to fetch has been blocked by CORS policy, ... No 'Access-Control-Allow-Origin' header is present on the requested resource"

I tried to modify my cors configuration (jasperserver-pro/WEB-INF/web.xml, ~ line 215) but it had no effect :

  <filter>
   <filter-name>CorsFilter</filter-name>
    <filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
    <init-param>
      <param-name>cors.allowed.origins</param-name>
      <param-value>http://fiddle.jshell.net, https://fiddle.jshell.net, http://localhost:4200, https://localhost:4200, https://srvreporting.arnaudjasper2.tk:4200, https://srvreporting.arnaudjasper2.tk:4200/vizjs-view, https://srvreporting.arnaudjasper2.tk:4200/auth</param-value>
    </init-param>
    <init-param>
      <param-name>cors.allowed.methods</param-name>
      <param-value>GET,POST,HEAD,PUT,OPTIONS,DELETE,PATCH</param-value>
    </init-param>
    <init-param>
      <param-name>cors.allowed.headers</param-name>
      <param-value>Cache-Control,X-Suppress-Basic,Origin,Accept,X-Requested-With,Content-Type,Pragma,accept-timezone,withCredentials,X-Remote-Domain,X-Is-Visualize,x-jrs-base-url,Content-Disposition,Content-Description</param-value>
    </init-param>
    <init-param>
      <param-name>cors.exposed.headers</param-name>
      <param-value>Access-Control-Allow-Origin,Access-Control-Allow-Credentials</param-value>
    </init-param>
    <init-param>
      <param-name>cors.support.credentials</param-name>
      <param-value>true</param-value>
    </init-param>
    <init-param>
      <param-name>cors.preflight.maxage</param-name>
      <!-- param value was 300 -->
      <param-value>1800</param-value>
    </init-param>
  </filter>

Do you have some advices ?

Thanks in advance for your help.

 

Best Regards,

jean-pierre

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Popular Days

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...