Skip to content

Create-cli defaults Axe/Lighthouse to localhost:4200 instead of detecting the app dev server port #1286

@kacperpaczos

Description

@kacperpaczos

What happened?

When running npm init @code-pushup/cli on a Vite + React project, the setup wizard prompts for target URLs for the Axe and Lighthouse plugins with a default of http://localhost:4200.

That port is correct for Angular/Nx, but Vite serves on http://localhost:5173 by default. Accepting the default (pressing Enter) writes the wrong URL into code-pushup.config.js. Web audits then fail unless the user manually changes the port.

Other wizard plugins already auto-detect project settings (ESLint config, tsconfig, package manager, test framework). Axe and Lighthouse do not — they use a hardcoded default:

  • packages/plugin-axe/src/lib/binding.tsconst DEFAULT_URL = 'http://localhost:4200'
  • packages/plugin-lighthouse/src/lib/binding.tsconst DEFAULT_URL = 'http://localhost:4200'

What would you expect to happen?

The wizard should detect the likely dev server URL from the project and use it as the default in the Target URL(s) prompt, for example:

  • Vite (vite.config.*, no custom port) → http://localhost:5173
  • Vite with server.port set → http://localhost:<port>
  • Angular/Nxhttp://localhost:4200 (or configured port)
  • Next.js (next dev in scripts) → http://localhost:3000
  • Unknown → fallback to 4200 with a note that the user should confirm

Optionally, the prompt could show where the suggestion came from, e.g.
Target URL(s) (detected from vite.config.js): http://localhost:5173

What steps did you take?

  1. Scaffold a Vite + React app:

    npm create vite@latest js-app -- --template react
    cd js-app
    npm install
    git init
  2. Run the Code PushUp setup wizard:

    npm init @code-pushup/cli
  3. Choose:

    • Setup mode: Standalone
    • Plugins: include Axe and Lighthouse (among others)
    • Config format: JavaScript
  4. For both Lighthouse and Axe, accept the default Target URL: http://localhost:4200

  5. Finish setup — code-pushup.config.js is created with:

    lighthousePlugin('http://localhost:4200')
    axePlugin('http://localhost:4200', { preset: 'all' })
  6. Start the app:

    npm run dev

    App runs at http://localhost:5173/

  7. Run Code PushUp:

    npx code-pushup collect
  8. Result: web audits target :4200 while the app is on :5173 — audits fail or produce no useful results until the URL is fixed manually.

Code PushUp package version

@code-pushup/create-cli@0.126.3

What operation system are you on?

Linux

Node version

v22.22.3

Relevant log output

Wizard output (URL defaults):


Lighthouse
✔ Target URL(s) (comma-separated): http://localhost:4200

Axe
✔ Target URL(s) (comma-separated): http://localhost:4200


Generated config excerpt:


const lhPlugin = lighthousePlugin('http://localhost:4200');
const axe = axePlugin('http://localhost:4200', { preset: 'all' });


Vite dev server (correct port):


VITE v8.0.16  ready in 436 ms
➜  Local:   http://localhost:5173/

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐛 bugsomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions