How to enable CORS in Grails 3.0.1

后端 未结 7 1315
有刺的猬
有刺的猬 2021-02-18 22:45

I would like to do cross origin communication using Grails in server side. The only documentation that I found is this one

https://grails.org/plugin/cors

but thi

7条回答
  •  别跟我提以往
    2021-02-18 23:08

    The cleanest and simplest solution for grails 3.1.x I found is to add the Apache default CorsFilter:

    import org.apache.catalina.filters.CorsFilter
    
    // Place your Spring DSL code here
    beans = {
        corsFilter(CorsFilter) //Custom CorsFilter under src/main/java/ works as well. I prefer Apache though...
    }
    

    The answer from #user215556 works as well but the default setting of the Apache Cors filter is ok as well

提交回复
热议问题