Access-Control-Allow-Headers header not being added in response for cors non simple request?

206 Views Asked by At

For the non simple cors request i am adding the following headers.

def testPostJSON(){


    response.setHeader("Access-Control-Allow-Origin", "*");
    response.setHeader("Access-Control-Allow-Credentials", "true");
    response.setHeader("Access-Control-Allow-Methods", "GET,HEAD,OPTIONS,POST,PUT");
    response.setHeader("Access-Control-Allow-Headers", "Access-Control-Allow-Headers, Origin,Accept, X-Requested-With, Content-Type, Access-Control-Request-Method, Access-Control-Request-Headers");

    render request.JSON.name

}

But you can see Access-Control-Allow-Headers is missing in the response headers. What is the reason it is missing? I am using Grails 2.2 for the server. Thanks for help!

enter image description here

1

There are 1 best solutions below

0
On

This plugin solved the problem.

https://grails.org/plugin/cors