Skip to content

Commit 837c945

Browse files
committed
Add workaround for CSRF issue in current GitHub Codespaces
1 parent 2cbb5e7 commit 837c945

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

spec/example_app/config/environments/development.rb

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

7676
# Apply autocorrection by RuboCop to files generated by `bin/rails generate`.
7777
# config.generators.apply_rubocop_autocorrect_after_generate!
78+
79+
# In the current GitHub Codespaces, the Origin header is rewritten, which breaks CSRF protection.
80+
# See: https://github.com/orgs/community/discussions/156532
81+
if ENV["GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN"] == "app.github.dev"
82+
warn "WARNING: (development) Disabling CSRF protection Origin header check!"
83+
config.action_controller.forgery_protection_origin_check = false
84+
end
7885
end

0 commit comments

Comments
 (0)