mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #5519] [Bug]: Unable to add headers for HTTP outbound traffic #3850
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#3850
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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.
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
@github-actions[bot] commented on GitHub (Jun 23, 2026):
This is a confirmed bug in the frontend outbound form adapter. The
headersfield 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.tsdefinesHttpOutboundServerSchemawith onlyaddress,port, andusersfields — noheaders. The companion form schema infrontend/src/schemas/forms/outbound-form.ts(lines 78–83,HttpOutboundFormSettingsSchema) similarly only knowsaddress,port,user, andpass.The adapter functions in
frontend/src/lib/xray/outbound-form-adapter.tstranslate between wire format and form state using two helpers shared by both SOCKS and HTTP:simpleAuthFromWire()(line 170): extracts onlyaddress,port,user,passfrom the raw JSON —headersis dropped on load.simpleAuthToWire()(line 482): reconstructs{ servers: [{ address, port, users }] }— noheadersis ever written back.When the user saves from the JSON editor tab (tab key
2), the flow inonOk()(line 302–317) still parses the raw JSON throughrawOutboundToFormValues()before passing the result toformValuesToWirePayload(). At that pointheadershas already been lost regardless of what was in the editor.The backend is not involved:
OutboundConfigsininternal/xray/config.gois typed asjson_util.RawMessage, so if the frontend ever sentheadersthe backend would preserve it faithfully.This bug also has a secondary interaction: if you add an outbound containing
headersvia 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, theheadersfield is lost at that point.Scope
This is specific to HTTP outbounds. The
headersfield is valid in xray-core at thesettingslevel (top-levelsettings.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
headersis preserved. Do not subsequently open and re-save that outbound through the Outbounds panel form, as doing so will stripheadersagain.A fix would require adding a
headersfield (typed asz.record(z.string()).optional()) to bothHttpOutboundSettingsSchemaandHttpOutboundServerSchema, extendingHttpOutboundFormSettingsSchemaaccordingly, and updatingsimpleAuthFromWire/simpleAuthToWireto round-trip that field.This reply was generated automatically; a maintainer may follow up.
@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-levelsettings.headerswas dropped on both load and save. The form now round-tripssettings.headersand exposes a headers editor for HTTP outbounds.Note: only the settings-level
headersmap is functional — xray-core's HTTP outbound config has no per-serverheadersfield, so the per-server form in your second example is ignored by xray regardless. Use the top-level form (your first example).