mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-26 17:51:13 +08:00
Enable CORS for PWA [SCI-4979]
This commit is contained in:
parent
48915b05f4
commit
7668e16419
3 changed files with 23 additions and 9 deletions
1
Gemfile
1
Gemfile
|
@ -37,6 +37,7 @@ gem 'jsonapi-renderer', '~> 0.2.2'
|
||||||
gem 'jwt', '~> 1.5'
|
gem 'jwt', '~> 1.5'
|
||||||
gem 'kaminari'
|
gem 'kaminari'
|
||||||
gem 'rack-attack'
|
gem 'rack-attack'
|
||||||
|
gem 'rack-cors'
|
||||||
|
|
||||||
# JS datetime library, requirement of datetime picker
|
# JS datetime library, requirement of datetime picker
|
||||||
gem 'momentjs-rails', '~> 2.17.1'
|
gem 'momentjs-rails', '~> 2.17.1'
|
||||||
|
|
|
@ -411,6 +411,8 @@ GEM
|
||||||
rack (2.2.3)
|
rack (2.2.3)
|
||||||
rack-attack (6.1.0)
|
rack-attack (6.1.0)
|
||||||
rack (>= 1.0, < 3)
|
rack (>= 1.0, < 3)
|
||||||
|
rack-cors (1.1.1)
|
||||||
|
rack (>= 2.0.0)
|
||||||
rack-proxy (0.6.5)
|
rack-proxy (0.6.5)
|
||||||
rack
|
rack
|
||||||
rack-test (1.1.0)
|
rack-test (1.1.0)
|
||||||
|
@ -668,6 +670,7 @@ DEPENDENCIES
|
||||||
pry-rails
|
pry-rails
|
||||||
puma
|
puma
|
||||||
rack-attack
|
rack-attack
|
||||||
|
rack-cors
|
||||||
rails (~> 6.0.0)
|
rails (~> 6.0.0)
|
||||||
rails-controller-testing
|
rails-controller-testing
|
||||||
rails_12factor
|
rails_12factor
|
||||||
|
|
|
@ -5,12 +5,22 @@
|
||||||
|
|
||||||
# Read more: https://github.com/cyu/rack-cors
|
# Read more: https://github.com/cyu/rack-cors
|
||||||
|
|
||||||
# Rails.application.config.middleware.insert_before 0, Rack::Cors do
|
if ENV['SCINOTE_PWA_DOMAIN_NAME'].present?
|
||||||
# allow do
|
Rails.application.config.middleware.insert_before 0, Rack::Cors do
|
||||||
# origins 'example.com'
|
allow do
|
||||||
#
|
origins ENV['SCINOTE_PWA_DOMAIN_NAME']
|
||||||
# resource '*',
|
|
||||||
# headers: :any,
|
resource '/oauth/token',
|
||||||
# methods: [:get, :post, :put, :patch, :delete, :options, :head]
|
headers: :any,
|
||||||
# end
|
methods: %i(post)
|
||||||
# end
|
|
||||||
|
resource '/rails/active_storage/*',
|
||||||
|
headers: :any,
|
||||||
|
methods: %i(get post options head)
|
||||||
|
|
||||||
|
resource '/api/*',
|
||||||
|
headers: :any,
|
||||||
|
methods: %i(get post put patch delete options head)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
Loading…
Reference in a new issue