且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Grails Rest API中使用CORS?

更新时间:2022-03-17 00:36:50

如果您使用的是Grails 3.2.1或更高版本,则它内置了CORS支持.

If you are using Grails 3.2.1 or higher, it comes with CORS support built in.

在您的application.yml中,添加以下内容:

In your application.yml, add the following:

grails:
    cors:
        enabled: true

请参见 http://docs.grails.org/latest/guide/Introduction.html#whatsNewCors 以获得更多详细信息.

See http://docs.grails.org/latest/guide/introduction.html#whatsNewCors for further details.