# CSP Errors Encountered During Local Deployment Supporting Both Ports 3000 and 80

**URL:** <https://forum.farmbot.org/t/csp-errors-encountered-during-local-deployment-supporting-both-ports-3000-and-80/9981>\
**Category:** Troubleshooting\
**Created:** [January 3, 2026, 10:27am UTC](https://forum.farmbot.org/t/csp-errors-encountered-during-local-deployment-supporting-both-ports-3000-and-80/9981 "2026-01-03T10:27:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ncnynl](https://forum.farmbot.org/letter_avatar_proxy/v4/letter/n/3d9bf3/32.png) [@ncnynl](https://forum.farmbot.org/u/ncnynl)\
**Post date:** [January 3, 2026, 10:27am UTC](https://forum.farmbot.org/t/csp-errors-encountered-during-local-deployment-supporting-both-ports-3000-and-80/9981/1 "2026-01-03T10:27:51Z")

</div>

Problem Description:

Following the official script deployment code, port 3000 is configured, and it can be accessed normally via xxx.xxx.xxx.xxx:3000.

However, when I try to access the website via `xxx.com` using nginx reverse proxy to xxx.xxx.xxx.xxx:3000, a CSP error occurs, preventing access via the domain name.

The error is as follows:  
connect-src xxx.xxx.xxx.xxx:3000 `xxx.com:3000` [api.github.com](http://api.github.com) [raw.githubusercontent.com](http://raw.githubusercontent.com) [api.rollbar.com](http://api.rollbar.com) xxx.xxx.xxx.xxx:3808 ws: localhost:3000 localhost:3808 [browser-http-intake.logs.datadoghq.com](http://browser-http-intake.logs.datadoghq.com) blob:

After reviewing the code, I found a default CSP entry. Modifying this code resolved the error and allowed access via the domain name.

`https://github.com/FarmBot/Farmbot-Web-App/blob/staging/config/application.rb`

Adding the desired domain name to the string in the `connect_src` definition solves the problem.

The code can also be modified accordingly.

The source code is:

```auto
ALL_LOCAL_URIS = ([ENV["API_HOST"]] + (ENV["EXTRA_DOMAINS"] || "").split(","))

.map { |x| x.present? ? "#{x}:#{ENV["API_PORT"]}" : nil }.compact

```

Regardless of whether the port in .env is 3000, all IPs or domains will automatically have this port added. In fact, it should also include the port number without it.

Similar to:  
`connect-src xxx.xxx.xxx.xxx:3000 xxx.com:3000 api.github.com raw.githubusercontent.com api.rollbar.com xxx.xxx.xxx.xxx:3808`

After modifying the code, it looks like:

```auto

ALL_LOCAL_URIS =

([ENV["API_HOST"]] + (ENV["EXTRA_DOMAINS"] || `"").split(","))

.map(&:presence)

.compact

.flat_map do |raw|

host, port = raw.split(":", 2)

uris = []

uris << host # without port

uris << "#{host}:#{port}" if port # originally with port

uris << "#{host}:#{ENV['API_PORT']}" if ENV["API_PORT"].present?

uris
end

.uniq

```

This will give all IPs and domains content with and without ports

`connect-src xxx.xxx.xxx.xxx:3000 , xxx.xxx.xxx.xxx, xxx.com:3000, xxx.com, api.github.com raw.githubusercontent.com api.rollbar.com xxx.xxx.xxx.xxx:3808`

This way, whether using an nginx reverse proxy or iptables to forward ports 80 to 3000, access will be normal.

This way, access via the domain `xxx.com` or via ip:3000 will be normal.

Is there a better way to solve this problem?

by the way

By comparing the efficiency of the official website and our self-deployed website, our website is significantly slower. The official website loads in about 10 seconds, while our self-deployed website takes about 25 seconds. We are using the ip:3000 domain. Our website is configured on a 4-core, 8GB RAM, 5Mbps bandwidth Ubuntu server.

Both the official and self-deployed websites seem somewhat slow. Is there room for optimization?

Current considerations:

1. Split all large JS and CSS files into multiple parts to speed up loading.

2. Caching static resources; the first load is slightly slower, but subsequent loads are faster.

3. Using gzip compression for transmission.

We are not yet very familiar with the official code; a deeper understanding of the architecture and further optimization is needed.

---

<div class="post-metadata">

**Author:** ![system](https://forum.farmbot.org/user_avatar/forum.farmbot.org/system/32/4564_2.png) [@system](https://forum.farmbot.org/u/system)\
**Post date:** [January 17, 2026, 10:28am UTC](https://forum.farmbot.org/t/csp-errors-encountered-during-local-deployment-supporting-both-ports-3000-and-80/9981/2 "2026-01-17T10:28:43Z")

</div>

Closed on January 17, 2026, 10:28am UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
