Configure CORS settings for StoriesController

- Storybook need to access through a GET method on `/rails/stories/**` served by `ViewComponent::Storybook::StoriesController`
 - Configure exact policy with an initialized filter
This commit is contained in:
Matt-Yorkley
2021-04-09 15:36:26 +01:00
committed by Jean-Baptiste Bellet
parent d674490896
commit 453328a97e

View File

@@ -0,0 +1,14 @@
# Adjust headers to allow running Storybook in development.
# Uses iframes and doesn't play nicely with CORS checks
if Rails.env.development?
module PermissiveCORSHeaders
def self.before(response)
response.headers["Access-Control-Allow-Origin"] = "*"
response.headers["Access-Control-Allow-Methods"] = "GET"
end
end
ViewComponent::Storybook::StoriesController.before_action(PermissiveCORSHeaders)
end