Skip to content

Commit fd919cf

Browse files
committed
create const for localhost:4200
1 parent 0947954 commit fd919cf

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

config/initializers/content_security_policy.rb

+4-3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#
1414
# :unsafe_eval, allows execution of eval statements
1515
# :unsafe_inline, allows inline resources usage
16+
FRONTEND_URL = 'http://localhost:4200'
1617

1718
policy.default_src :none unless Rails.env.development?
1819
policy.font_src :self, "http://localhost:4200/text-security-disc-compat.eot?#iefix",
@@ -22,13 +23,13 @@
2223
policy.connect_src :self, 'https://sentry.puzzle.ch'
2324

2425
policy.font_src :self
25-
policy.font_src :self, :https, 'http://localhost:4200', :data if Rails.env.development?
26+
policy.font_src :self, :https, FRONTEND_URL, :data if Rails.env.development?
2627

2728
policy.script_src :self
28-
policy.script_src :self, :unsafe_eval, "http://localhost:4200" if Rails.env.development?
29+
policy.script_src :self, :unsafe_eval, FRONTEND_URL if Rails.env.development?
2930

3031
policy.style_src :self, :unsafe_inline
31-
policy.style_src :self, :unsafe_inline, "http://localhost:4200" if Rails.env.development?
32+
policy.style_src :self, :unsafe_inline, FRONTEND_URL if Rails.env.development?
3233

3334
# If you are using webpack-dev-server then specify webpack-dev-server host
3435
policy.connect_src :self, "http://localhost:3035", "ws://localhost:4200" if Rails.env.development?

0 commit comments

Comments
 (0)