grails拦截跨域访问请求


class ApiInterceptor {

boolean before() {

    println "before::::=================="

    header( "Access-Control-Allow-Origin","*")// 这里的*注意一下允许所有人调用"http://local.test" )

    header( "Access-Control-Allow-Credentials", "true" )

    header( "Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE" )

    header( "Access-Control-Max-Age", "3600" )

    true

}

boolean after() { 

    true

 }

void afterView() {

    // no-op

}

}


你可能感兴趣的:(grails拦截跨域访问请求)