-
Notifications
You must be signed in to change notification settings - Fork 635
Description
When self-hosting, the Connect UI connects to https://api.nango.dev instead of the configured backend (e.g. http://localhost:3003), unless the apiUrl param is explicitly passed.
Step by step
- Request for a new session via API
- Build the connect URL, or use the "magic link" to access the Connect UI
- Open the browser on the URL
Observations:
- Page shows error that session is expired
- Network tab shows connection request to api.nango.dev instead ot localhost
Expected:
The Connect UI should always use the configured backend URL based on config/environment or the apiUrl param, without needing a manual override each time.
Note: I have used GH Copilot to validate my env-vars and config, and it came up with a root cause analysis. I can't validate this personally, but maybe it points in the right direction.
This is most likely due to a hardcoded default in the Connect UI store and a race condition where the store is updated after the initial request.
Suggestion is to update the store.ts, so that it would read the environment vars. (This is bt Copilot / Claude)
// Read from URL params first, then env var, then default
const getInitialApiURL = () => {
const params = new URLSearchParams(window.location.search);
const urlApiURL = params.get('apiURL');
if (urlApiURL) return urlApiURL;
// This would be replaced at build time via Vite
return import.meta.env.VITE_API_URL || 'https://api.nango.dev';
};
export const useGlobal = create<State>((set) => ({
// ... other fields
apiURL: getInitialApiURL(),
// ... rest
}));My Setup
Version: nangohq/nango-server:hosted-0.69.31
The environment variables i tried to set
# Nango Server Configuration
NANGO_SERVER_URL=http://localhost:3003
NANGO_SERVICE_URL=http://localhost:3003
SERVER_SERVICE_URL=http://localhost:3003
NANGO_PUBLIC_SERVER_URL=http://localhost:3003
SERVER_PORT=3003
SERVER_HOST=localhost
# Nango Connect UI Configuration
NANGO_CONNECT_UI_PORT=3009
NANGO_PUBLIC_CONNECT_URL=http://localhost:3009