Skip to content

Bug: --serverUrl CLI flag has no effect on API client requests #195

@codxbrexx

Description

@codxbrexx

Description

In metacall-deploy, the --serverUrl (-u) CLI flag is parsed but applied to the internal configuration after the api client has been initialized. As a result, the provided custom URL is completely ignored during the execution of deployment commands.

The API client falls back to the default baseURL (e.g., https://api.metacall.io or the cached config). Currently, the only way to override the target URL locally is by using the hardcoded --dev flag, which always sets the target to localhost:9000.

Steps to Reproduce

  1. Execute metacall-deploy using a custom --serverUrl, for example:
    metacall-deploy --serverUrl http://custom-faas-server.local:9000 --workdir .
  2. Observe the network traffic or CLI output. The CLI connects to the default API (https://api.metacall.io) instead of the specified custom URL.

Expected Behavior

The API client should instantiate using the base URL provided via the --serverUrl parameter, allowing deployments to a custom self-hosted or remote FaaS instance.

Actual Behavior

The API client instantiates using the default configuration, and the --serverUrl parameter is applied to the script's config state at the very end of index.ts, well after the API client has been utilized.

Root Cause

In deploy/src/index.ts, the api object is initialized with config.baseURL:

Image

However, the override from the CLI arguments is only checked at the end of the script line 178:

	if (args['serverUrl']) {
		config.baseURL = args['serverUrl'];
	}
})();

Proposed Fix

Apply the configuration override before initializing the API client:

const config = await startup(args['confDir']);

// Fix: Apply --serverUrl override before API client creation
if (args['serverUrl']) {
	config.baseURL = args['serverUrl'];
}

const api: APIInterface = API(
	config.token as string,
	args['dev'] ? config.devURL : config.baseURL
);

I'm willing to resolve this issue.

Note: The --dev flag should be removed in the future.

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