Playframework 2.0 动态更改CORS-允许起源-播放2.4.x

Playframework 2.0 动态更改CORS-允许起源-播放2.4.x,playframework-2.0,Playframework 2.0,我需要动态更改Play 2.4.x的允许原点 我有下面的代码,但无法访问“corsFilter.corsConfig.allowedOrigins” 我相信一定有一个简单的解决方案来定制游戏CORS import javax.inject.Inject import play.api.http.HttpFilters import play.filters.cors.CORSFilter class Filters @Inject() (corsFilter: CORSFilter) ext

我需要动态更改Play 2.4.x的允许原点

我有下面的代码,但无法访问“corsFilter.corsConfig.allowedOrigins”

我相信一定有一个简单的解决方案来定制游戏CORS

import javax.inject.Inject

import play.api.http.HttpFilters
import play.filters.cors.CORSFilter

class Filters @Inject() (corsFilter: CORSFilter) extends HttpFilters {
  def filters: Seq[CORSFilter] = {
    Seq(corsFilter)
  }
}
application.conf

play.http.filters = "Filters"
play.filters.cors {

  pathPrefixes = ["/"]
  allowedOrigins =  ["http://localhost", "http://localhost:8888", "http://localhost:9000"]
  allowedHttpMethods = ["GET", "POST", "PUT", "DELETE", "OPTIONS"]
  # The allowed HTTP headers. If null, all headers are allowed.
  allowedHttpHeaders = ["Origin", "X-Requested-With", "Content-Type", "Accept", "Referer", "User-Agent", "access_token"]
  # The exposed headers
  exposedHeaders = ["Origin", "X-Requested-With", "Content-Type", "Accept", "Referer", "User-Agent", "access_token"]
  # Whether to support credentials
  supportsCredentials = false
  # The maximum amount of time the CORS meta data should be cached by the client
  preflightMaxAge = 1 hour
}