Skip to content

Conversation

@Omar-Nabil2
Copy link

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.

Copilot AI review requested due to automatic review settings January 31, 2026 06:46
Copy link

Copilot AI left a 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=default query parameter.
  • Added server and tenant selection state in the login page, persisting both to localStorage and wiring the server dropdown into the UI.
  • Refactored the shared Axios instance to derive its baseURL dynamically from localStorage.mifosServer and set the Fineract-Platform-TenantId header from localStorage.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.

Comment on lines 10 to 15
export const loginFineract = async (username: string, password: string) => {
const response = await fineract.post(
'/authentication',
{ username, password },
{
params: {
tenantIdentifier: 'default',
},
}
{ username, password }
)
return response.data
Copy link

Copilot AI Jan 31, 2026

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.

Copilot uses AI. Check for mistakes.
Comment on lines 24 to 35
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
}
Copy link

Copilot AI Jan 31, 2026

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.

Copilot uses AI. Check for mistakes.
@Omar-Nabil2 Omar-Nabil2 changed the title fix server dropdown list MXWAR-44 :- fix server dropdown list Jan 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant