我正在处理一个使用 Rails 4 的遗留项目,其中使用了 rack-cors gem 来允许跨域资源共享。我知道有一个选项可以将某个域名添加到白名单中。
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的所有域名。我在文档中找不到将特定域名添加到黑名单的任何信息。
是否有其他实现方式?提前感谢您的帮助。