-
Notifications
You must be signed in to change notification settings - Fork 4.6k
[Bug]:loginToServer sends multipart/form-data instead of application/x-www-form-urlencoded #2820
Description
Bug Report: Login Form Fails Silently When AUTH_MODE is Enabled
Checklist
- [] I have searched the existing issues and this bug is not already filed.
- [] I believe this is a legitimate bug, not just a question or feature request.
Description
When LightRAG is deployed on a server with authentication configured via `AUTH_ACCOUNTS` and `TOKEN_SECRET` in the `.env` file, accessing the server IP via browser navigates to the login page. However, upon entering valid credentials and clicking Login, the form fails with a "Login failed, please check username and password" message on screen Inspecting the browser console reveals `ERR_EMPTY_RESPONSE` on the `POST /login` request
Root cause: The frontend sends the request as multipart/form-data, but FastAPI's OAuth2PasswordRequestForm requires application/x-www-form-urlencoded. The required grant_type=password field is also missing from the request body.
Steps to Reproduce
- Deploy LightRAG with the following `.env` configuration:
AUTH_ACCOUNTS= TOKEN_SECRET= - Open WebUI at
/webui/#/login - Enter valid username and password
- Click Login
- Browser returns
ERR_EMPTY_RESPONSEor login fails with no token returned
Expected Behavior
Login should succeed, return a valid JWT token, and redirect the user into the WebUI.
LightRAG Config
AUTH_ACCOUNTS=
TOKEN_SECRET=
Root Cause Analysis
File: lightrag_webui/src/api/lightrag.ts (~line 922)
code:
// Wrong: sends as multipart/form-data
const formData = new FormData()
formData.append('username', username)
formData.append('password', password)
// Missing: grant_type=password
Fixed code:
// Correct: sends as application/x-www-form-urlencoded
const formData = new URLSearchParams()
formData.append('username', username)
formData.append('password', password)
formData.append('grant_type', 'password')
Additional Information
| Field | Value |
|---|---|
| LightRAG Version | 1.4.10 (API: 0272) |
| Operating System | Ubuntu 20.04 |
| Python Version | 3.12 |
| Related Issues | — |