Make your REST API compatible with Internet Explorer

25 / Jul / 2016 by Sachin Grover 0 comments

You might wonder when you find your REST API’s are working properly in all browsers and rest clients but not in IE. I got the same issue in my project. I am sharing the issue and solution with you so that you can resolve it if you get the same.

In rest APIs, I had some parameters in header for user validation and other region related like X-Auth-Token, Content-Country. In the front end, we are using AngularJS for API consumption, so we were getting proper results in all browsers except IE. IE was showing following error in console:

SEC7123: Request header content-country was not present in the Access-Control-Allow-Headers list.

IE makes headers in small case whether it entered in capitalized case. To resolve this issue I have made changes in CORS filters in application side. I changed capitalized headers to small case headers. like this.

response.setHeader("Access-Control-Allow-Headers", "x-auth-token, content-country");

After making the above changes, my APIs are working properly in all browsers.

FOUND THIS USEFUL? SHARE IT

Leave a Reply

Your email address will not be published. Required fields are marked *