The personal finance app for everyone (by everyone)
Ruby
fix(devcontainer): use configured session key in Codespaces (#2982)
William Wei Ming1d1ecd3c4623
diff --git a/config/application.rb b/config/application.rbindex 8f9fdca531..e506ecf112 100644--- a/config/application.rb+++ b/config/application.rb@@ -7,6 +7,10 @@ require "rails/all"Bundler.require(*Rails.groups)module Sure+ # Matches Rails::Application::Finisher#setup_default_session_store for Sure::Application+ # ("_#{railtie_name.chomp("_application")}_session" → "_sure_session").+ SESSION_COOKIE_KEY = "_sure_session"+class Application < Rails::Application# Initialize configuration defaults for originally generated Rails version.config.load_defaults 8.1@@ -24,6 +28,9 @@ module Sure# config.time_zone = "Central Time (US & Canada)"# config.eager_load_paths << Rails.root.join("extras")+ # Explicit source of truth for the session cookie name (also used by Codespaces).+ config.session_store :cookie_store, key: SESSION_COOKIE_KEY+# TODO: This is here for incremental adoption of localization. This can be removed when all translations are implemented.config.i18n.fallbacks = truediff --git a/config/initializers/codespaces.rb b/config/initializers/codespaces.rbindex dc44956b9d..784c0b7b33 100644--- a/config/initializers/codespaces.rb+++ b/config/initializers/codespaces.rb@@ -15,8 +15,14 @@ if Rails.env.development? && ENV["CODESPACES"] == "true"# If you use the VS Code "Preview" (iframe), you need SameSite=None; Secure# Codespaces serves over HTTPS, so secure: true is OK here.+ # Re-declare the cookie store so we can set Codespaces-only cookie flags, but+ # keep Sure::SESSION_COOKIE_KEY (set in config/application.rb) so the cookie+ # name stays consistent with non-Codespaces boots. Do not read+ # session_options[:key] here as the "source of truth" — calling session_store+ # replaces those options, and this file used to hardcode "_app_session", which+ # diverged from Rails' default "_sure_session".Rails.application.config.session_store :cookie_store,- key: "_app_session",+ key: Sure::SESSION_COOKIE_KEY,same_site: :none,secure: trueend