angular/angular-cli · warning

Warning: --deploy-url and/or --base-href contain unsupported

Error message

Warning: --deploy-url and/or --base-href contain unsupported values for ng serve. Default serve path of '/' used. Use --serve-path to override.

What it means

In the dev-server webpack config, when no explicit servePath is given, findDefaultServePath computes one from baseHref/deployUrl. If those values are incompatible/unsupported (null result), the builder falls back to serving at '/' and logs this warning.

Source

Thrown at packages/angular_devkit/build_angular/src/tools/webpack/configs/dev-server.ts:107

      proxy: await addProxyConfig(root, proxyConfig),
      ...getWebSocketSettings(wco.buildOptions, servePath),
    },
  };
}

/**
 * Resolve and build a URL _path_ that will be the root of the server. This resolved base href and
 * deploy URL from the browser options and returns a path from the root.
 */
export function buildServePath(
  options: WebpackDevServerOptions,
  logger: logging.LoggerApi,
): string {
  let servePath = options.servePath;
  if (servePath === undefined) {
    const defaultPath = findDefaultServePath(options.baseHref, options.deployUrl);
    if (defaultPath == null) {
      logger.warn(tags.oneLine`
        Warning: --deploy-url and/or --base-href contain unsupported values for ng serve. Default
        serve path of '/' used. Use --serve-path to override.
      `);
    }
    servePath = defaultPath || '';
  }

  if (servePath.endsWith('/')) {
    servePath = servePath.slice(0, -1);
  }

  if (!servePath.startsWith('/')) {
    servePath = `/${servePath}`;
  }

  return servePath;
}

View on GitHub (pinned to bb72145f9a)

Solutions

  1. Pass an explicit --serve-path (or servePath option in angular.json) to define the served path.
  2. Remove or simplify --deploy-url/--base-href during local serving; keep them only for production builds.
  3. If a custom path is needed, set servePath explicitly instead of relying on the automatic derivation.

Example fix

// before
ng serve --base-href /app/ --deploy-url https://cdn.example.com/app/
// after
ng serve --serve-path /app/
Defensive patterns

Strategy: validation

Validate before calling

// Validate deploy-url/base-href before serving:
function validServePath(baseHref, deployUrl, servePath) {
  if (servePath) return true;
  if (deployUrl && /^https?:\/\//.test(deployUrl)) return false;
  if (baseHref && !/^(\/[^*]*)?$/.test(baseHref)) return false;
  return true;
}

Prevention

When it happens

Trigger: Running `ng serve` with --deploy-url and/or --base-href values that cannot be combined into a valid default serve path, and no --serve-path supplied.

Common situations: Using absolute deploy URLs (e.g., https://cdn.example.com/app/) or unusual base-href with ng serve; assets seem served at wrong path.

Related errors


AI-assisted analysis of angular/angular-cli@bb72145f9a (2026-08-30). Data as JSON: /api/errors/33d9b33b888d400d. Report an issue: GitHub.