mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 19:11:53 +07:00
[PR #5203] [MERGED] fix: derive JSON/Clash subscription URLs from configured subURI #5818
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#5818
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?
📋 Pull Request Information
Original PR: https://github.com/MHSanaei/3x-ui/pull/5203
Author: @w3struk
Created: 6/11/2026
Status: ✅ Merged
Merged: 6/11/2026
Merged by: @MHSanaei
Base:
main← Head:main📝 Commits (3)
7aa912afix: derive JSON/Clash subscription URLs from configured subURIc59192aMerge branch 'main' into mainfd14c6afix(sub): fall back to request base when configured subURI is unparseable📊 Changes
2 files changed (+75 additions, -2 deletions)
View changed files
📝
internal/sub/build_urls_test.go(+48 -0)📝
internal/sub/service.go(+27 -2)📄 Description
Description
When
subURIis explicitly configured (reverse-proxy setup with Caddy/Nginx) butsubJsonURIorsubClashURIare not,BuildSubURIBasegenerates URLs using the raw sub-server port (2096) and HTTP scheme, producing broken links on the subscription info page (e.g.,http://domain:2096/json/SUB_IDinstead ofhttps://domain/sub-xxx/json/SUB_ID).Root Cause
BuildURLs(internal/sub/service.go:2112) usesBuildSubURIBaseas the fallback base for all unconfigured subscription URLs.BuildSubURIBase(internal/web/service/setting.go:1003) has no knowledge of the reverse proxy — it always builds URLs from the raw sub-server settings (port 2096, no TLS →http://domain:2096).The main
subURLworks correctly becausebuildSingleURL(line 2133) returns the explicitly configuredsubURIdirectly when set. But JSON and Clash URLs fall through toBuildSubURIBasewhen their respective URIs are empty.Fix
In
BuildURLs, whensubURIis configured, extract its scheme+host via a newextractBaseFromURIhelper and use that as the base for all unconfigured sibling URLs instead ofBuildSubURIBase.This ensures JSON and Clash Copy URLs on the subscription page inherit the correct scheme+host from the configured subURI:
http://domain:2096/json/SUB_IDhttps://domain/sub-xxx/json/SUB_IDFiles Changed
internal/sub/service.go: modifiedBuildURLsto derive base from configured subURI; addedextractBaseFromURIhelperinternal/sub/build_urls_test.go: addedTestBuildURLs_DerivesJsonFromConfiguredSubURITesting
Related Issue
Fixes incorrect subscription page JSON/Clash URLs when running 3x-ui behind a reverse proxy with configured subURI.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.