[GH-ISSUE #5348] [Feature]: JSON subscription page #3745

Closed
opened 2026-10-31 20:34:39 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @forwork10 on GitHub (Jun 15, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5348

Currently, when opening a standard subscription link in a web browser, i see normal UI. However, if a user opens a JSON subscription link (/json) directly in a browser, it only displays the raw JSON code.

Describe the solution you'd like

I would like the JSON subscription endpoint to detect if the request comes from a standard web browser (via User-Agent headers).

  • If opened in a browser, it should render a nice UI page showing QR codes, copy buttons, and client statistics.
  • If requested by a VPN client, it should continue to return the raw JSON payload as it does now.

Alternatives you've considered

I made my own custom subserver (running 3xui subserver on a local port), but it's not very convenient.

Concrete use case

Regular subscription links can be used in VPN services, where you can view statistics and import a subscription into the client. This is convenient because you don't need to implement the subscription import logic yourself, etc. I would like to see the same functionality for JSON/Clash subscriptions.

Mockups, screenshots, or examples

No response

Which parts of the panel would this affect?

Subscription (share links / Clash / JSON)

Are you willing to help?

  • I'd like to implement this feature myself and open a PR.
  • I can help test once a PR is open.

Before submitting

  • I searched existing issues and this feature has not been requested.
  • This feature request is written in English.
Originally created by @forwork10 on GitHub (Jun 15, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5348 ### Is your feature request related to a problem? Currently, when opening a standard subscription link in a web browser, i see normal UI. However, if a user opens a JSON subscription link (/json) directly in a browser, it only displays the raw JSON code. ### Describe the solution you'd like I would like the JSON subscription endpoint to detect if the request comes from a standard web browser (via User-Agent headers). - If opened in a browser, it should render a nice UI page showing QR codes, copy buttons, and client statistics. - If requested by a VPN client, it should continue to return the raw JSON payload as it does now. ### Alternatives you've considered I made my own custom subserver (running 3xui subserver on a local port), but it's not very convenient. ### Concrete use case Regular subscription links can be used in VPN services, where you can view statistics and import a subscription into the client. This is convenient because you don't need to implement the subscription import logic yourself, etc. I would like to see the same functionality for JSON/Clash subscriptions. ### Mockups, screenshots, or examples _No response_ ### Which parts of the panel would this affect? Subscription (share links / Clash / JSON) ### Are you willing to help? - [ ] I'd like to implement this feature myself and open a PR. - [ ] I can help test once a PR is open. ### Before submitting - [x] I searched [existing issues](../issues?q=is%3Aissue) and this feature has not been requested. - [x] This feature request is written in English.
bsakaguchi 2026-10-31 20:34:39 +07:00
Author
Owner

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

The standard subscription endpoint already has exactly the browser-detection behaviour you are describing; the JSON endpoint does not. Here is what the code shows:

Standard endpoint (subs handler, internal/sub/controller.go:137-183) — already implemented. When the request carries Accept: text/html, or the query string contains ?html=1 / ?view=html, the handler calls serveSubPage, which injects window.__SUB_PAGE_DATA__ into the embedded React SPA (internal/web/dist/subpage.html). That page renders traffic stats, QR codes, and copy buttons. VPN clients that do not send an HTML Accept header receive the base64-encoded proxy list as before.

JSON endpoint (subJsons handler, internal/sub/controller.go:342-358) — no browser detection. It unconditionally calls subJsonService.GetJson(subId, host) and returns the raw JSON string, regardless of the requester's Accept header or User-Agent.

What an implementation would need to do:

  1. In subJsons, add the same Accept/query-param check that already exists in subs (lines 150-167 of controller.go).
  2. When a browser is detected, call subService.GetSubs(subId, host) to retrieve the traffic, emails, last-online, and proxy links needed to populate PageData.
  3. Pass that to the existing a.serveSubPage(c, basePathStr, page) call — no new HTML or frontend work required, since serveSubPage and the SPA are already generic.

The same approach could be applied to the Clash endpoint (subClashs, lines 360-378) if that is also desired.

A PR for this change would be straightforward and can reuse the existing infrastructure without touching the frontend or the SubJsonService logic.

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

<!-- gh-comment-id:4708353420 --> @github-actions[bot] commented on GitHub (Jun 15, 2026): The standard subscription endpoint already has exactly the browser-detection behaviour you are describing; the JSON endpoint does not. Here is what the code shows: **Standard endpoint (`subs` handler, `internal/sub/controller.go:137-183`)** — already implemented. When the request carries `Accept: text/html`, or the query string contains `?html=1` / `?view=html`, the handler calls `serveSubPage`, which injects `window.__SUB_PAGE_DATA__` into the embedded React SPA (`internal/web/dist/subpage.html`). That page renders traffic stats, QR codes, and copy buttons. VPN clients that do not send an HTML Accept header receive the base64-encoded proxy list as before. **JSON endpoint (`subJsons` handler, `internal/sub/controller.go:342-358`)** — no browser detection. It unconditionally calls `subJsonService.GetJson(subId, host)` and returns the raw JSON string, regardless of the requester's `Accept` header or User-Agent. **What an implementation would need to do:** 1. In `subJsons`, add the same Accept/query-param check that already exists in `subs` (lines 150-167 of `controller.go`). 2. When a browser is detected, call `subService.GetSubs(subId, host)` to retrieve the traffic, emails, last-online, and proxy links needed to populate `PageData`. 3. Pass that to the existing `a.serveSubPage(c, basePathStr, page)` call — no new HTML or frontend work required, since `serveSubPage` and the SPA are already generic. The same approach could be applied to the Clash endpoint (`subClashs`, lines 360-378) if that is also desired. A PR for this change would be straightforward and can reuse the existing infrastructure without touching the frontend or the `SubJsonService` logic. *This reply was generated automatically; a maintainer may follow up.*
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#3745
No description provided.