Allow Cross-origin resource sharing for GitLab API
It will allow to write web applications on other domains to interact with GitLab instances Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
parent
23d180f5f1
commit
6edb4c0634
3 changed files with 11 additions and 0 deletions
1
Gemfile
1
Gemfile
|
@ -44,6 +44,7 @@ gem "gitlab-linguist", "~> 2.9.6", require: "linguist"
|
||||||
# API
|
# API
|
||||||
gem "grape", "~> 0.4.1"
|
gem "grape", "~> 0.4.1"
|
||||||
gem "grape-entity", "~> 0.3.0"
|
gem "grape-entity", "~> 0.3.0"
|
||||||
|
gem 'rack-cors', require: 'rack/cors'
|
||||||
|
|
||||||
# Format dates and times
|
# Format dates and times
|
||||||
# based on human-friendly examples
|
# based on human-friendly examples
|
||||||
|
|
|
@ -335,6 +335,7 @@ GEM
|
||||||
rack
|
rack
|
||||||
rack-cache (1.2)
|
rack-cache (1.2)
|
||||||
rack (>= 0.4)
|
rack (>= 0.4)
|
||||||
|
rack-cors (0.2.9)
|
||||||
rack-mini-profiler (0.1.31)
|
rack-mini-profiler (0.1.31)
|
||||||
rack (>= 1.1.3)
|
rack (>= 1.1.3)
|
||||||
rack-mount (0.8.3)
|
rack-mount (0.8.3)
|
||||||
|
@ -610,6 +611,7 @@ DEPENDENCIES
|
||||||
pry
|
pry
|
||||||
quiet_assets (~> 1.0.1)
|
quiet_assets (~> 1.0.1)
|
||||||
rack-attack
|
rack-attack
|
||||||
|
rack-cors
|
||||||
rack-mini-profiler
|
rack-mini-profiler
|
||||||
rails (= 3.2.16)
|
rails (= 3.2.16)
|
||||||
rails-dev-tweaks
|
rails-dev-tweaks
|
||||||
|
|
|
@ -79,5 +79,13 @@ module Gitlab
|
||||||
# config.relative_url_root = "/gitlab"
|
# config.relative_url_root = "/gitlab"
|
||||||
|
|
||||||
config.middleware.use Rack::Attack
|
config.middleware.use Rack::Attack
|
||||||
|
|
||||||
|
# Allow access to GitLab API from other domains
|
||||||
|
config.middleware.use Rack::Cors do
|
||||||
|
allow do
|
||||||
|
origins '*'
|
||||||
|
resource '/api/*', headers: :any, methods: [:get, :post, :options, :put]
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue