Allow CSP API hosts with and without ports - #2522
Open
Daniiiil1 wants to merge 1 commit into
Open
Conversation
Daniiiil1
marked this pull request as ready for review
August 7, 2026 03:34
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.
What changed\n\n- Preserve each API host and EXTRA_DOMAINS entry as a valid CSP connect-src source without a port.\n- Also add the configured API_PORT variant when a port is present.\n- Deduplicate the resulting source list.\n- Add a regression spec covering the API host with and without its configured port.\n\n## Why\n\nSelf-hosted deployments commonly place nginx on the public default port while Rails listens on API_PORT (usually 3000). The previous code only emitted host:API_PORT, so browser requests through the public domain could be blocked by the Content Security Policy.\n\n## Impact\n\nBoth direct access to the Rails port and access through a reverse proxy can use the same environment configuration without manually editing application.rb.\n\nFixes #2505\n\n## Validation\n\n- ruby -c config/application.rb\n- ruby -c spec/config/application_spec.rb\n- git diff --check\n\nThe full suite was not run locally because this checkout requires Ruby 4.0.6 and Bun, which are not installed in the current environment.