Use HTTPS + secure cookies in all deployed environments#89
Merged
Conversation
…duction default_url_options and the session cookie's secure flag keyed on Rails.env.production?, so any non-production *deployed* environment (e.g. staging) generated http://host:3000 URLs and non-secure session cookies. Behind a TLS-terminating proxy that broke navigation — e.g. the login redirect pointed at http://app.<host>:3000/session/new, which isn't reachable. Key on Rails.env.local? instead (matching the gem's existing idiom): development and test keep http + the local port; every deployed env (production, staging, ...) gets https with no port and secure cookies.
There was a problem hiding this comment.
Pull request overview
This PR updates Upright’s environment-based URL generation and session cookie configuration so that any non-local (i.e., deployed) environment defaults to HTTPS URLs and secure cookies, while keeping local development/test behavior unchanged.
Changes:
- Switch session cookie
secureflag to be enabled in all non-local environments. - Switch
default_url_optionsto use HTTPS outside local environments, and keep HTTP + port only for local. - Keep existing host/domain behavior intact while removing the “http://…:3000” default from deployed non-prod environments (e.g., staging).
Tip
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| lib/upright/engine.rb | Enables secure session cookies in all non-local environments. |
| lib/upright/configuration.rb | Makes generated URLs HTTPS by default outside local dev/test, avoiding http://...:3000 in deployed envs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Key
default_url_optionsand the session cookiesecureflag onRails.env.local?instead ofRails.env.production?, so deployed non-prod envs (staging) get https + secure cookies instead of unreachablehttp://host:3000URLs. Dev/test unchanged.