dotnet/aspnetcore · error · Error

No url defined.

Error message

No url defined.

What it means

Thrown by FetchHttpClient.send() when request.url is falsy (undefined/empty). The fetch call needs a concrete URL, so the client rejects early. DefaultHttpClient.send also emits the same message, so it surfaces from either path. It means the HttpRequest was constructed without a URL.

Source

Thrown at src/SignalR/clients/ts/signalr/src/FetchHttpClient.ts:69

            // Node needs EventListener methods on AbortController which our custom polyfill doesn't provide
            this._abortControllerType = requireFunc("abort-controller");
        } else {
            this._abortControllerType = AbortController;
        }
    }

    /** @inheritDoc */
    public async send(request: HttpRequest): Promise<HttpResponse> {
        // Check that abort was not signaled before calling send
        if (request.abortSignal && request.abortSignal.aborted) {
            throw new AbortError();
        }

        if (!request.method) {
            throw new Error("No method defined.");
        }
        if (!request.url) {
            throw new Error("No url defined.");
        }

        const abortController = new this._abortControllerType();

        let error: any;
        // Hook our abortSignal into the abort controller
        if (request.abortSignal) {
            request.abortSignal.onabort = () => {
                abortController.abort();
                error = new AbortError();
            };
        }

        // If a timeout has been passed in, setup a timeout to call abort
        // Type needs to be any to fit window.setTimeout and NodeJS.setTimeout
        let timeoutId: any = null;
        if (request.timeout) {
            const msTimeout = request.timeout!;

View on GitHub (pinned to 294cab2f9b)

Solutions

  1. Use httpClient.get(url)/.post(url, options) which require the url as the first parameter.
  2. If calling send directly, always populate request.url.
  3. Validate url is a non-empty string before building the request.
  4. Check the source of the URL (env var, config) is defined at runtime.

Example fix

// before
await httpClient.send({ method: 'POST', url: process.env.HUB_URL });
// process.env.HUB_URL is undefined -> throws

// after
const url = process.env.HUB_URL;
if (!url) throw new Error('HUB_URL not configured');
await httpClient.post(url, { content: body });
Defensive patterns

Strategy: validation

Validate before calling

function assertRequest(req: { method?: string; url?: string }) {
  if (!req.url) throw new Error('HttpRequest.url is required');
  if (!req.method) throw new Error('HttpRequest.method is required');
}
assertRequest(request);
await httpClient.send(request);

Type guard

function hasUrl(req: { url?: string }): req is { url: string } {
  return typeof req.url === 'string' && req.url.length > 0;
}

Try / catch

try {
  await httpClient.send(request);
} catch (e) {
  if (e.message === 'No url defined.') {
    throw new Error('Configuration missing: provide a valid hub URL');
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling httpClient.send({ method: 'POST' }) with no url; passing an empty string url; a config object whose url was conditionally undefined.

Common situations: Building the request from a config whose url resolved to undefined (env var missing); a custom wrapper that forgets to propagate url; calling send directly instead of the get/post helpers that take a url argument.

Related errors


AI-assisted analysis of dotnet/aspnetcore@294cab2f9b (2026-08-06). Data as JSON: /api/errors/152018cb828a2e8e. Report an issue: GitHub.