Skip to content

Commit

Permalink
move CORS setup to initializer
Browse files Browse the repository at this point in the history
  • Loading branch information
yksflip committed Jun 9, 2023
1 parent 20a67be commit 4bfa87d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 20 deletions.
11 changes: 0 additions & 11 deletions config/application.rb
Expand Up @@ -68,17 +68,6 @@ class Application < Rails::Application
config.active_record.yaml_column_permitted_classes = [Symbol, BigDecimal]

config.autoloader = :zeitwerk

# Ex:- :default =>''

# CORS for API
config.middleware.insert_before 0, Rack::Cors do
allow do
origins '*'
# this restricts Foodsoft scopes to certain characters - let's discuss it when it becomes an actual problem
resource %r{\A/[-a-zA-Z0-9_]+/api/v1/}, headers: :any, methods: :any
end
end
end

# Foodsoft version
Expand Down
16 changes: 7 additions & 9 deletions config/initializers/cors.rb
Expand Up @@ -5,12 +5,10 @@

# Read more: https://github.com/cyu/rack-cors

# Rails.application.config.middleware.insert_before 0, Rack::Cors do
# allow do
# origins "example.com"
#
# resource "*",
# headers: :any,
# methods: [:get, :post, :put, :patch, :delete, :options, :head]
# end
# end
Rails.application.config.middleware.insert_before 0, Rack::Cors do
allow do
origins '*'
# this restricts Foodsoft scopes to certain characters - let's discuss it when it becomes an actual problem
resource %r{\A/[-a-zA-Z0-9_]+/api/v1/}, headers: :any, methods: :any
end
end

0 comments on commit 4bfa87d

Please sign in to comment.