mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 19:11:53 +07:00
[GH-ISSUE #6386] [Bug]: subscription language #4332
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#4332
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 @ArtinTomcat on GitHub (Sep 1, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6386
Describe the bug
when users change their subscription language , the language on xray panel also changes too
How to reproduce the problem
.
Expected behavior
No response
Actual behavior
No response
Relevant logs
Screenshots
No response
3x-ui version
3.7.0
Xray-core version
No response
How did you install 3x-ui?
install.sh script
Operating system
Ubuntu 24
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 (Sep 1, 2026):
Confirmed — the subscription page and the panel share one single browser cookie for the UI language, so changing it on one changes it on the other. This is a real defect, but it only travels inside one browser: a client changing the language on their own subscription page cannot change the language you see in your panel.
Why it happens
The panel language is not stored server-side at all. There is no
webLangsetting — the only language key in the database istgLangfor the Telegram bot (internal/web/service/setting.go:83). Both the panel and the subscription page read the language from the same cookie:LanguageManager.setLanguage()(frontend/src/utils/index.ts:940-946) writes that cookie, and it is called from both places with no distinction:frontend/src/pages/sub/SubPage.tsx:98-101frontend/src/pages/settings/GeneralTab.tsx:153-156Both bundles then read it back through the same
LanguageManager.getLanguage()(frontend/src/utils/index.ts:900) at i18n startup (frontend/src/i18n/react.ts:18).The cookie is written with
path=/and noDomainattribute, and cookies are scoped by host, not by port. By default the subscription server listens on a different port but the same hostname —"subPort": "2096"and"subDomain": ""(internal/web/service/setting.go:103-105), and an emptysubDomainfalls back to the panel's own hostname (internal/web/service/setting.go:1416-1417). Sohttps://example.com:2096/sub/...andhttps://example.com:2053/panel/share the exact samelangcookie.Workarounds today
frontend/src/pages/settings/GeneralTab.tsx:319). It is the same cookie, so it wins whichever page wrote it last.subDomainsetting (internal/web/service/setting.go:826, read atinternal/sub/sub.go:58). Different host = different cookie jar, so the two stop interfering.A separate, genuinely cross-user coupling (for the maintainer)
While tracing this I found a second one that does cross users, though it does not affect the UI language.
LocalizerMiddlewareassigns a package-level global from the current request's cookie:That middleware is installed on the public subscription server too (
internal/sub/sub.go:219), and both servers run in one process (main.go:120-122).I18nWebresolves through that same global (internal/web/controller/base.go:41→internal/web/locale/locale.go:83), and it backs ~280 API response messages acrossinternal/web/controller/. So an anonymous subscriber'slangcookie can flip the language of an admin's API messages mid-flight, and the unsynchronised write to a shared global is a data race. This is a distinct defect from the one reported above and would rate higher than it.Verdict: Confirmed bug
Severity: Low
Confidence: Medium
Root cause:
CookieManager.setCookiewrites thelangcookie withpath=/and noDomain(frontend/src/utils/index.ts:791);LanguageManager.setLanguage(frontend/src/utils/index.ts:940-946) is called unchanged from bothSubPage.tsx:100andGeneralTab.tsx:155, and both bundles read it back viafrontend/src/i18n/react.ts:18. Triggers whenever the subscription page and the panel are reached on the same hostname (the default:subDomainis""and falls back to the panel host,internal/web/service/setting.go:1416-1417), in the same browser. The subscription-page language selector arrived with the frontend rewrite inedf0f369("Frontend rewrite: React + TypeScript with AntD v6 (#4498)"), which is the only commit touchingonLangChangeinSubPage.tsx.Already fixed: Still present on the default branch (
f727d04f, v3.7.0 — the latest release pergh release list).Duplicate of: None. Related: #3807, the request that added a language selector to the subscription page.
Evidence:
frontend/src/utils/index.ts:791document.cookie = cname + '=' + encodeURIComponent(cvalue) + ';' + expires + 'path=/';;frontend/src/utils/index.ts:944CookieManager.setCookie('lang', language, 365);;frontend/src/utils/index.ts:900let lang = CookieManager.getCookie('lang');;frontend/src/i18n/react.ts:18let active: string = LanguageManager.getLanguage();;internal/web/service/setting.go:103-105"subPort": "2096","subPath": "/sub/","subDomain": "";internal/web/locale/locale.go:142LocalizerWeb = i18n.NewLocalizer(i18nBundle, lang);internal/sub/sub.go:219engine.Use(locale.LocalizerMiddleware()). No test in the repo pins the shared-cookie behaviour as intended, and no comment defends it.Not determined: Whether you observed this in one browser (fully explained above) or believe a client's change reached your panel. The single check that settles it: open the panel in a private window while a client is using the subscription page — if the panel is still in your language there, it was the shared cookie in your own browser. I could not run the panel or read any screenshot here, so please paste text rather than images if you follow up.
Suggested fix: Give the subscription page its own persisted language key instead of routing through the shared
path=/langcookie thatLanguageManagerowns (frontend/src/utils/index.ts:791), soSubPage.tsx:100andGeneralTab.tsx:155no longer write the same slot. TheLocalizerWebglobal is a separate change: make the localizer request-scoped (it is already placed in the gin context atinternal/web/locale/locale.go:144) rather than assigned to a package variable.A clearer title for searchability would be "changing the language on the subscription page also changes the panel language".
This reply was generated automatically; a maintainer may follow up.
@dawNotPoi commented on GitHub (Sep 3, 2026):
I'd like to work on this. I'll keep the panel and login on the existing
langcookie, give the subscription SPA an independent language scope with a one-time migration from a valid existing selection, and add focused regression coverage for initialization and date formatting. I won't change the backend localizer as part of this fix.