From e7ef49a43086e67b368eba0c76ec171adb9e33c9 Mon Sep 17 00:00:00 2001 From: Royal <88779808+royalpriest@users.noreply.github.com> Date: Wed, 18 Nov 2026 23:05:42 +0000 Subject: [PATCH] Fix signing in from GitHub Codespaces Codespaces proxies HTTPS to plain HTTP, so the Origin header never matched and Rails rejected every form post with InvalidAuthenticityToken. Skip the origin check in development when running in a codespace. The authenticity token is still verified. --- config/environments/development.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/config/environments/development.rb b/config/environments/development.rb index e5893a2..b0480e8 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -4,6 +4,11 @@ # Let GitHub Codespaces open the app through its forwarded address. config.hosts << ".app.github.dev" + # Codespaces serves the app over HTTPS through a proxy that talks plain HTTP to Rails, so the + # browser's Origin header never matches and every form post would fail the CSRF origin check. + # The authenticity token is still checked. + config.action_controller.forgery_protection_origin_check = false if ENV["CODESPACES"] + # Settings specified here will take precedence over those in config/application.rb. # Make code changes take effect immediately without server restart.