mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #5622] [Bug]: API endpoints return 404 in 3x-ui v3.4.1 #3922
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#3922
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 @hellousersxx on GitHub (Jun 27, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5622
Describe the bug
After updating to 3x-ui v3.4.1, the documented API endpoints are not accessible.
The panel is available and works normally through the web interface. The API documentation is also available at:
https://:/<BASE_PATH>/panel/api-docs
I generated an API Token in Settings -> Security and used it as a Bearer token as described in the documentation.
However, every documented API endpoint returns 404 Not Found.
I also tested the login endpoints (/login, /panel/login and /<BASE_PATH>/login). They return 404 or 403.
According to the documentation, programmatic clients should authenticate using a Bearer API Token, so I expected the documented API endpoints to work.
How to reproduce the problem
Expected behavior
The API should authenticate using the Bearer token and return the requested data (or at least 401/403 if the token is invalid).
Actual behavior
The server responds with:
HTTP/1.1 404 Not Found
The same happens for the documented API endpoints.
The login endpoints also return 404 or 403.
Relevant logs
Screenshots
No response
3x-ui version
3.4.1
Xray-core version
26.6.22
How did you install 3x-ui?
install.sh script
Operating system
Ubuntu
Which parts of the panel are affected?
Backend (API endpoints, login, settings)
Browser (only if it is a UI bug)
No response
Is the panel behind a reverse proxy or CDN?
Yes — Cloudflare Tunnel
Before submitting
@github-actions[bot] commented on GitHub (Jun 27, 2026):
The 404 you are seeing from API endpoints is intentional behavior in
internal/web/controller/api.go: when a non-XHR request reaches/<BASE_PATH>/panel/api/...and Bearer token authentication fails, the server returns 404 (not 401) to avoid revealing that the endpoint exists. The 403 on/<BASE_PATH>/loginis the CSRF middleware rejecting a POST that arrives without a priorX-CSRF-Tokenheader. Both behaviors are by design and do not indicate a routing problem.The core question is why your Bearer token is not passing auth. Based on the code path in
ApiTokenService.Match(internal/web/service/panel/api_token.go:116-133) and your Cloudflare Tunnel setup, there are three things to rule out in order.Step 1 — Confirm the header reaches 3x-ui (bypass Cloudflare)
Run this directly on the server so the request goes to 3x-ui without touching Cloudflare:
200: the token and URL are correct and Cloudflare is the problem (see Step 2).404: the token is not being recognized — go to Step 3.Step 2 — Cloudflare Access stripping the Authorization header
Cloudflare Zero Trust (Cloudflare Access) removes the
Authorizationheader before forwarding requests to the origin and replaces it with aCF-Access-Jwt-Assertionheader. If your Cloudflare Tunnel has an Access application protecting it, your Bearer token is silently dropped before 3x-ui ever sees it.Check in the Cloudflare dashboard under Zero Trust → Access → Applications whether there is a policy covering your panel's hostname or path. If so, you have two options:
/panel/api/path to let API requests through without Access authentication.Even without an Access application, verify that no HTTP header modification rules (Transform Rules) in your Cloudflare zone strip or overwrite the
Authorizationheader.Step 3 — Regenerate the token
Tokens are stored as SHA-256 hashes (
internal/web/service/panel/api_token.go:78). The plaintext is shown exactly once at creation. If there was any copy-paste issue (trailing newline, invisible character, partial copy), the hash will not match.Go to Settings → Security, delete the existing token, create a new one, and copy it immediately from the panel before navigating away.
Step 4 — Confirm the full URL
The entire panel is mounted under the randomly-generated base path (
internal/web/web.go:246). API endpoints are at:The paths
/login,/panel/loginreturning 404 is expected — the login endpoint only exists at/<BASE_PATH>/login(POST), and the 403 you saw there is the CSRF protection rejecting a POST without aX-CSRF-Tokenheader obtained from/<BASE_PATH>/csrf-tokenfirst.To help diagnose further, please share:
curltest from Step 1 (redact the token itself; just the HTTP status code is enough).x-ui→ Show Panel Settings (orx-ui setting -show), specifically the base path.This reply was generated automatically; a maintainer may follow up.
@hellousersxx commented on GitHub (Jun 27, 2026):
Could you please clarify why this was closed as "not planned"?
I tested the request locally on the server, bypassing Cloudflare, and the documented API endpoint still returns 404 with a valid API token.
If this is expected behavior, could you point me to the correct API endpoint or explain what is wrong with my request?
@Sup4ik-cmd commented on GitHub (Jun 29, 2026):
curl -X 'GET' '
'https://ip:your_port/base/panel/api/inbounds/list'
-H 'accept: application/json'
-H 'Authorization: Bearer api_token'
-k
Try this out and see if it gives you a json response