Skip to content

Commit bc68b7c

Browse files
committed
Add development CORS policy for Storybook
1 parent ee6b52b commit bc68b7c

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ gem "jbuilder", "~> 2.7"
3434

3535
gem "view_component", require: "view_component/engine"
3636
gem "view_component_storybook"
37+
gem "rack-cors"
3738

3839
group :development, :test do
3940
# Call "byebug" anywhere in the code to stop execution and get a debugger console

Gemfile.lock

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ GEM
138138
nio4r (~> 2.0)
139139
racc (1.5.2)
140140
rack (2.2.3)
141+
rack-cors (1.1.1)
142+
rack (>= 2.0.0)
141143
rack-test (1.1.0)
142144
rack (>= 1.0, < 3)
143145
rails-dom-testing (2.0.3)
@@ -191,6 +193,7 @@ DEPENDENCIES
191193
importmap-rails (>= 0.3.4)
192194
jbuilder (~> 2.7)
193195
puma (~> 5.0)
196+
rack-cors
194197
rails!
195198
selenium-webdriver
196199
sqlite3 (~> 1.4)

config/environments/development.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,11 @@
6464

6565
# Uncomment if you wish to allow Action Cable access from any origin.
6666
# config.action_cable.disable_request_forgery_protection = true
67+
68+
config.middleware.insert_before 0, Rack::Cors do
69+
allow do
70+
origins '*'
71+
resource '/rails/stories/*', :headers => :any, :methods => [:get]
72+
end
73+
end
6774
end

0 commit comments

Comments
 (0)