Search code examples
ajaxrestresteasyjboss-eap-7

No 'Access-Control-Allow-Origin' header is present on the requested resource does not apply to postman


I have implemented a restful service. I have tested it using an ajax request within the application and also with postman client and both worked. But when i try to send an ajax request from a different application i get the below error in browser console.

http://localhost:8080/AusIncomeCalculator/AUSTax/post. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8089' is therefore not allowed access.

I don't understand how the postman client get a successful response while the other applications cannot.

RESTful service is hosted in JBOSS-eap 7.0 with rest easy


Solution

  • What happen is for security reasons, browsers restrict cross-origin HTTP requests initiated from within scripts.Postman is a REST Client that runs as an application inside the Chrome browser. It is specifically designed for testing rest APIs, and therefore it doesn't restrict cross origin resource request.