How to enable CORS in Grails 3.0.1

后端 未结 7 1312
有刺的猬
有刺的猬 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:09

    If you need to enable CORS for endpoints provided by the Spring Security core/rest plugins you have to add this:

    Bootstrap.groovy:

    SpringSecurityUtils.clientRegisterFilter("corsFilter",
        SecurityFilterPosition.SECURITY_CONTEXT_FILTER.order - 1)
    

    resources.groovy:

    beans = {
        corsFilter(CorsFilter)
    }
    

提交回复
热议问题