lundi 5 août 2019

My Application is not responding to the request given by front end and throwing a CORS exception

I have created a web service using dropwizard application.

  1. Through this I am able to create resources package wherein I have created entity for indexing the document, search request, getting doc by id.

  2. By hitting the api in postman I get the desired result.

  3. For developing the web application I built the front end using ember.js.

  4. But when I send request to my application I am getting CORS policy exception.

    • When I am sending request through postman to http://localhost:9090 (9090 is the port number of my ApplicationConnector) then it is respnding to the request.
    • Now when I send request from origin http://localhost:4200 (4200is the default port number for ember.js) to http://localhost:9090 it is giving error :

Access to XMLHttpRequest at http://localhost:9090/{indexName}/{id} >from origin http://localhost:4200 has been blocked by CORS policy: Response to preflight request doesn't pass access control check:
No 'Access->Control-Allow-Origin' header is present on the requested resource.

So can someone please explain how to resolve this issue and if there is any other way apart from enabling CORS in Dropwizard ?




Aucun commentaire:

Enregistrer un commentaire