Skip to content

Allow CSP API hosts with and without ports - #2522

Open
Daniiiil1 wants to merge 1 commit into
FarmBot:stagingfrom
Daniiiil1:codex/farmbot-csp-origin-variants
Open

Allow CSP API hosts with and without ports#2522
Daniiiil1 wants to merge 1 commit into
FarmBot:stagingfrom
Daniiiil1:codex/farmbot-csp-origin-variants

Conversation

@Daniiiil1

Copy link
Copy Markdown

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.

@Daniiiil1
Daniiiil1 marked this pull request as ready for review August 7, 2026 03:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant