0

I'm getting CORB (Cross Origin Read Blocking) error when I tried to get response from my jQuery ajax request. It's working properly on Internet Explorer but when I tried to run it on Chrome I'm getting the error.

$(function() {
  var URL_PREFIX = "http://ptrisd01:8983/solr/archiveCore/select?fl=PackName&group.field=PackName&group=true&q=PackName%3A*&rows=13&sort=PackName%20asc&start=0&wt=json";
  var URL = URL_PREFIX;
  
  $.ajax({
    url: URL,
    success: function(data) {
      var docs = JSON.stringify(data.grouped.PackName.groups);
      var jsonData = JSON.parse(docs);
      for (var i = 0; i < jsonData.length; i++) {
        $("#PackName").append($("<option>" + jsonData[i].groupValue + "</option>"));
      }
    },
    dataType: 'jsonp',
    crossDomain: true,
    type: 'get',
    json: 'json.wrf',
  })
});

The error that I'm getting on Chrome like in below

corb

Is there any solution for the error I'm getting?

UPDATE

According to advice of @Rory, I have made some research about how to enable CORS for Apache Solr because its running on my http://ptrisd01:8983 server. I found the below solution in the following link : https://community.bitnami.com/t/enable-cors-for-solr/81806/4

Add below codes to solr's /server/solr-webapp/webapp/WEB-INF/web.xml file.

<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>GET,POST,OPTIONS,DELETE,PUT,HEAD</param-value>
    </init-param>
    <init-param>
      <param-name>allowedHeaders</param-name>
      <param-value>origin, content-type, cache-control, accept, options, authorization, x-requested-with</param-value>
    </init-param>
    <init-param>
      <param-name>supportsCredentials</param-name>
      <param-value>true</param-value>
    </init-param>
  </filter>
  <filter-mapping>
    <filter-name>cross-origin</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
demir5334
  • 215
  • 7
  • 17
  • 1
    It works in Internet Explorer because it's an incredibly outdated and insecure browser. All modern browsers will prevent you from making a cross-domain AJAX request. To solve the issue you need to enable CORS on the `http://ptrisd01:8983` domain - note this is done in your ***server side*** configuration, not in JS. – Rory McCrossan May 10 '22 at 10:49
  • @RoryMcCrossan Thank you for your advice. My Apache Solr runs on **http://ptrisd01:8983**. I searched to add CORS to Apache Solr and found the solution in following link **https://community.bitnami.com/t/enable-cors-for-solr/81806/5** – demir5334 May 10 '22 at 11:15

0 Answers0