[GH-ISSUE #5519] [Bug]: Unable to add headers for HTTP outbound traffic #3850

Closed
opened 2026-10-31 20:35:24 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @SatenRuiko-Lv0 on GitHub (Jun 23, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5519

Describe the bug

When adding the following two formats to the 3xui outbound list or XRay final configuration, 3xui automatically removes the headers field. This results in the outbound connection failing. We hope to support custom headers for HTTP outbound.

{
  "protocol": "http",
  "settings": {
    "servers": [
      {
        "address": "cloudnproxy.n.shifen.com",
        "port": 443,
        "users": []
      }
    ],
    "headers": {
      "X-T5-Auth": "683556433",
      "Host": "153.3.236.22:443"
    }
  },
  "tag": "百度直连"
}
{
  "protocol": "http",
  "settings": {
    "servers": [
      {
        "address": "cloudnproxy.n.shifen.com",
        "port": 443,
        "users": [],
        "headers": {
        "X-T5-Auth": "683556433",
        "Host": "153.3.236.22:443"
        }
      }
    ]
  },
  "tag": "百度直连"
}

How to reproduce the problem

Just what the title says

Expected behavior

I hope we can allow custom outbound headers.

Actual behavior

No response

Relevant logs


Screenshots

No response

3x-ui version

3.4.0

Xray-core version

26.6.22

How did you install 3x-ui?

install.sh script

Operating system

Debain12

Which parts of the panel are affected?

No response

Browser (only if it is a UI bug)

No response

Is the panel behind a reverse proxy or CDN?

None

Before submitting

  • I searched existing issues and this bug has not been reported.
  • I am running the latest released version of 3x-ui (or have verified the bug still exists on it).
  • This bug report is written in English.
  • I have redacted any sensitive data (tokens, real domains, client UUIDs).
Originally created by @SatenRuiko-Lv0 on GitHub (Jun 23, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5519 ### Describe the bug When adding the following two formats to the 3xui outbound list or XRay final configuration, 3xui automatically removes the headers field. This results in the outbound connection failing. We hope to support custom headers for HTTP outbound. ``` { "protocol": "http", "settings": { "servers": [ { "address": "cloudnproxy.n.shifen.com", "port": 443, "users": [] } ], "headers": { "X-T5-Auth": "683556433", "Host": "153.3.236.22:443" } }, "tag": "百度直连" } ``` ``` { "protocol": "http", "settings": { "servers": [ { "address": "cloudnproxy.n.shifen.com", "port": 443, "users": [], "headers": { "X-T5-Auth": "683556433", "Host": "153.3.236.22:443" } } ] }, "tag": "百度直连" } ``` ### How to reproduce the problem Just what the title says ### Expected behavior I hope we can allow custom outbound headers. ### Actual behavior _No response_ ### Relevant logs ```shell ``` ### Screenshots _No response_ ### 3x-ui version 3.4.0 ### Xray-core version 26.6.22 ### How did you install 3x-ui? install.sh script ### Operating system Debain12 ### Which parts of the panel are affected? _No response_ ### Browser (only if it is a UI bug) _No response_ ### Is the panel behind a reverse proxy or CDN? None ### Before submitting - [x] I searched [existing issues](../issues?q=is%3Aissue) and this bug has not been reported. - [x] I am running the latest released version of 3x-ui (or have verified the bug still exists on it). - [x] This bug report is written in English. - [x] I have redacted any sensitive data (tokens, real domains, client UUIDs).
bsakaguchi 2026-10-31 20:35:24 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@github-actions[bot] commented on GitHub (Jun 23, 2026):

This is a confirmed bug in the frontend outbound form adapter. The headers field is silently discarded for HTTP outbounds whenever an outbound is added or edited through the Outbounds panel.

Root cause

The HTTP outbound schema in frontend/src/schemas/protocols/outbound/http.ts defines HttpOutboundServerSchema with only address, port, and users fields — no headers. The companion form schema in frontend/src/schemas/forms/outbound-form.ts (lines 78–83, HttpOutboundFormSettingsSchema) similarly only knows address, port, user, and pass.

The adapter functions in frontend/src/lib/xray/outbound-form-adapter.ts translate between wire format and form state using two helpers shared by both SOCKS and HTTP:

  • simpleAuthFromWire() (line 170): extracts only address, port, user, pass from the raw JSON — headers is dropped on load.
  • simpleAuthToWire() (line 482): reconstructs { servers: [{ address, port, users }] } — no headers is ever written back.

When the user saves from the JSON editor tab (tab key 2), the flow in onOk() (line 302–317) still parses the raw JSON through rawOutboundToFormValues() before passing the result to formValuesToWirePayload(). At that point headers has already been lost regardless of what was in the editor.

The backend is not involved: OutboundConfigs in internal/xray/config.go is typed as json_util.RawMessage, so if the frontend ever sent headers the backend would preserve it faithfully.

This bug also has a secondary interaction: if you add an outbound containing headers via the Xray Settings textarea (which sends the raw string directly and does not go through the adapter), then later open and save that same outbound through the Outbounds panel form, the headers field is lost at that point.

Scope

This is specific to HTTP outbounds. The headers field is valid in xray-core at the settings level (top-level settings.headers) as well as per-server (settings.servers[].headers), neither of which is represented in the current schema.

Related

Issue #4459 by the same reporter described this as an enhancement request and was closed without being implemented. The schemas and adapter are unchanged from that report; this issue accurately describes the behavior as a destructive data loss bug.

Workaround (until fixed)

Add the HTTP outbound directly in the Xray Settings textarea rather than through the Outbounds panel form. The textarea route sends the raw JSON string to the backend without passing through the adapter, so headers is preserved. Do not subsequently open and re-save that outbound through the Outbounds panel form, as doing so will strip headers again.

{
  "protocol": "http",
  "settings": {
    "servers": [
      {
        "address": "cloudnproxy.n.shifen.com",
        "port": 443,
        "users": []
      }
    ],
    "headers": {
      "X-T5-Auth": "683556433",
      "Host": "153.3.236.22:443"
    }
  },
  "tag": "your-tag"
}

A fix would require adding a headers field (typed as z.record(z.string()).optional()) to both HttpOutboundSettingsSchema and HttpOutboundServerSchema, extending HttpOutboundFormSettingsSchema accordingly, and updating simpleAuthFromWire / simpleAuthToWire to round-trip that field.

This reply was generated automatically; a maintainer may follow up.

<!-- gh-comment-id:4783343986 --> @github-actions[bot] commented on GitHub (Jun 23, 2026): This is a confirmed bug in the frontend outbound form adapter. The `headers` field is silently discarded for HTTP outbounds whenever an outbound is added or edited through the Outbounds panel. **Root cause** The HTTP outbound schema in `frontend/src/schemas/protocols/outbound/http.ts` defines `HttpOutboundServerSchema` with only `address`, `port`, and `users` fields — no `headers`. The companion form schema in `frontend/src/schemas/forms/outbound-form.ts` (lines 78–83, `HttpOutboundFormSettingsSchema`) similarly only knows `address`, `port`, `user`, and `pass`. The adapter functions in `frontend/src/lib/xray/outbound-form-adapter.ts` translate between wire format and form state using two helpers shared by both SOCKS and HTTP: - `simpleAuthFromWire()` (line 170): extracts only `address`, `port`, `user`, `pass` from the raw JSON — `headers` is dropped on load. - `simpleAuthToWire()` (line 482): reconstructs `{ servers: [{ address, port, users }] }` — no `headers` is ever written back. When the user saves from the JSON editor tab (tab key `2`), the flow in `onOk()` (line 302–317) still parses the raw JSON through `rawOutboundToFormValues()` before passing the result to `formValuesToWirePayload()`. At that point `headers` has already been lost regardless of what was in the editor. The backend is not involved: `OutboundConfigs` in `internal/xray/config.go` is typed as `json_util.RawMessage`, so if the frontend ever sent `headers` the backend would preserve it faithfully. This bug also has a secondary interaction: if you add an outbound containing `headers` via the Xray Settings textarea (which sends the raw string directly and does not go through the adapter), then later open and save that same outbound through the Outbounds panel form, the `headers` field is lost at that point. **Scope** This is specific to HTTP outbounds. The `headers` field is valid in xray-core at the `settings` level (top-level `settings.headers`) as well as per-server (`settings.servers[].headers`), neither of which is represented in the current schema. **Related** Issue #4459 by the same reporter described this as an enhancement request and was closed without being implemented. The schemas and adapter are unchanged from that report; this issue accurately describes the behavior as a destructive data loss bug. **Workaround (until fixed)** Add the HTTP outbound directly in the Xray Settings textarea rather than through the Outbounds panel form. The textarea route sends the raw JSON string to the backend without passing through the adapter, so `headers` is preserved. Do not subsequently open and re-save that outbound through the Outbounds panel form, as doing so will strip `headers` again. ```json { "protocol": "http", "settings": { "servers": [ { "address": "cloudnproxy.n.shifen.com", "port": 443, "users": [] } ], "headers": { "X-T5-Auth": "683556433", "Host": "153.3.236.22:443" } }, "tag": "your-tag" } ``` A fix would require adding a `headers` field (typed as `z.record(z.string()).optional()`) to both `HttpOutboundSettingsSchema` and `HttpOutboundServerSchema`, extending `HttpOutboundFormSettingsSchema` accordingly, and updating `simpleAuthFromWire` / `simpleAuthToWire` to round-trip that field. *This reply was generated automatically; a maintainer may follow up.*
Author
Owner

@MHSanaei commented on GitHub (Jun 24, 2026):

Fixed in commit bd60e770.

The Outbounds panel form routed HTTP outbounds through the SOCKS-shared adapter, which only handled address/port/user/pass — so xray's top-level settings.headers was dropped on both load and save. The form now round-trips settings.headers and exposes a headers editor for HTTP outbounds.

Note: only the settings-level headers map is functional — xray-core's HTTP outbound config has no per-server headers field, so the per-server form in your second example is ignored by xray regardless. Use the top-level form (your first example).

<!-- gh-comment-id:4789235802 --> @MHSanaei commented on GitHub (Jun 24, 2026): Fixed in commit bd60e770. The Outbounds panel form routed HTTP outbounds through the SOCKS-shared adapter, which only handled `address`/`port`/`user`/`pass` — so xray's top-level `settings.headers` was dropped on both load and save. The form now round-trips `settings.headers` and exposes a headers editor for HTTP outbounds. Note: only the settings-level `headers` map is functional — xray-core's HTTP outbound config has no per-server `headers` field, so the per-server form in your second example is ignored by xray regardless. Use the top-level form (your first example).
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#3850
No description provided.