-
Notifications
You must be signed in to change notification settings - Fork 18
MXWAR-44 :- fix server dropdown list #39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR aims to make the login flow respect the selected server from the UI and remove the hardcoded localhost base URL and tenant query parameter. It introduces localStorage-backed server and tenant selection and wires that into the Axios client configuration.
Changes:
- Updated the login API call to stop passing a hardcoded
tenantIdentifier=defaultquery parameter. - Added server and tenant selection state in the login page, persisting both to
localStorageand wiring the server dropdown into the UI. - Refactored the shared Axios instance to derive its
baseURLdynamically fromlocalStorage.mifosServerand set theFineract-Platform-TenantIdheader fromlocalStorage.mifosTenant.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/pages/login/loginApi.ts |
Removes the hardcoded tenantIdentifier=default query parameter from the /authentication request. |
src/pages/login/Login.tsx |
Adds server and tenant state, persists them to localStorage, and binds them to the server and tenant <Select> components. |
src/lib/axios.ts |
Introduces getBaseURL() and updates the Axios instance to read server and tenant from localStorage on each request, dynamically adjusting baseURL and tenant header. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| export const loginFineract = async (username: string, password: string) => { | ||
| const response = await fineract.post( | ||
| '/authentication', | ||
| { username, password }, | ||
| { | ||
| params: { | ||
| tenantIdentifier: 'default', | ||
| }, | ||
| } | ||
| { username, password } | ||
| ) | ||
| return response.data |
Copilot
AI
Jan 31, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing the tenantIdentifier query parameter here means the login request no longer sends any tenant information, and because the Axios interceptor only adds the Fineract-Platform-TenantId header when a token is present, unauthenticated /authentication calls will always be made without a tenant. This breaks tenant selection for non-default tenants and can cause login to fail; the login request should include the selected tenant (e.g., via header or query parameter) using the value stored in localStorage.
| fineract.interceptors.request.use(config => { | ||
| const token = localStorage.getItem('mifosToken') | ||
| const tenant = localStorage.getItem('mifosTenant') || 'default' | ||
| const server = localStorage.getItem('mifosServer') || 'https://localhost:8443' | ||
|
|
||
| // Update baseURL dynamically in case it changed | ||
| config.baseURL = `${server}/fineract-provider/api/v1` | ||
|
|
||
| if (token) { | ||
| config.headers['Authorization'] = `Basic ${token}` | ||
| config.headers['Fineract-Platform-TenantId'] = 'default' | ||
| config.headers['Fineract-Platform-TenantId'] = tenant | ||
| } |
Copilot
AI
Jan 31, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this interceptor, the Fineract-Platform-TenantId header is only set when a token exists, so the initial unauthenticated login request to /authentication never carries the tenant value even though the UI lets the user select a tenant and stores it in localStorage. To make tenant selection effective (especially for non-default tenants), the tenant header should be applied independently of whether a token is present, so that the login call also uses the selected tenant.
Description
Server dropdown wasn't applied - login requests always went to hardcoded localhost:8443 instead of selected server. I have added state tracking, localStorage persistence, dynamic axios baseURL, and removed tenantIdentifier query parameter.
Screenshots, if any
before
before.mp4
after
after.mp4
Checklist
Please make sure these boxes are checked before submitting your pull request - thanks!
If you have multiple commits please combine them into one commit by squashing them.
Read and understood the contribution guidelines at
CONTRIBUTING.md.