Skip to content

Connect UI defaults to api.nango.dev instead of respecting config #5432

@michaelschnyder

Description

@michaelschnyder

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

  1. Request for a new session via API
  2. Build the connect URL, or use the "magic link" to access the Connect UI
  3. 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
Image

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions