【发布时间】:2020-05-05 07:39:34
【问题描述】:
我正在 Rails 4 中的一个遗留项目上工作,其中 rack-cors gem 用于允许 CORS。我知道可以选择将域列入白名单。
use Rack::Cors do
allow do
origins 'localhost:3000', '127.0.0.1:3000',
/\Ahttp:\/\/192\.168\.0\.\d{1,3}(:\d+)?\z/
# regular expressions can be used here
resource '/file/list_all/', :headers => 'x-domain-token'
resource '/file/at/*',
methods: [:get, :post, :delete, :put, :patch, :options, :head],
headers: 'x-domain-token',
expose: ['Some-Custom-Response-Header'],
max_age: 600
# headers to expose
end
end
是否有任何选项可以将域列入黑名单,以便为该特定域禁用 CORS。我试图弄清楚这一点,因为我无法真正找到项目中使用 API 的所有域。我在文档中找不到将特定域列入黑名单的任何内容。
还有其他方法可以实现吗?我在这里先向您的帮助表示感谢。
【问题讨论】:
标签: ruby-on-rails ruby rack-cors