Skip to content

Dev server host binding and SSL certificate trust #18

@MichaelSchmidle

Description

@MichaelSchmidle

Problem

When running light up (development mode), Traefik proxies https://app.lvh.mehttp://host.docker.internal:3000, but most dev servers fail with Error 500 due to:

  1. Host binding: Vite/Nuxt/Next dev servers bind to localhost by default (not accessible from Docker containers)
  2. SSL certificate trust: Dev servers making requests to https://api.lvh.me don't trust mkcert certificates

Current Workaround

Users must manually update their dev script:

{
  "dev": "NODE_EXTRA_CA_CERTS=\"$(mkcert -CAROOT)/rootCA.pem\" nuxt dev --host"
}

This requires users to:

  • Know about the --host flag for their framework
  • Know about mkcert root CA location
  • Manually configure each project

Proposed Solution (Option B + light dev wrapper)

Interactive Setup During light init

Detect dev script and offer to update it:

✓ Lightstack project 'playground' initialized

⚠️  Dev server configuration needed:
  Your "dev" script may not be accessible from Traefik proxy.
  
  Current: "nuxt dev"
  Suggested: "NODE_EXTRA_CA_CERTS=\"$(mkcert -CAROOT)/rootCA.pem\" nuxt dev --host"
  
  Update package.json? [Y/n]

Alternative: light dev Wrapper Command

Provide light dev command that wraps user's dev server with correct configuration:

  • Auto-detects framework (Nuxt, Vite, Next, etc.)
  • Adds --host flag
  • Sets NODE_EXTRA_CA_CERTS to mkcert root CA
  • Executes user's dev command with proper env vars

Update "Next steps" output:

Next steps:
  Start your app: light dev
  (Or manually: bun dev --host with mkcert CA trusted)

Hybrid Approach (Recommended)

  1. During light init: Offer to update dev script interactively
  2. Provide light dev: As fallback for users who decline the update
  3. Document in output: Show troubleshooting tips if users use manual bun dev

User Preference

Users prefer Option B (interactive update) because:

  • Most devs will instinctively run <package-manager> run dev (muscle memory)
  • Remembering to use light dev is extra cognitive load across many projects
  • Interactive fix during init is one-time setup, then forgotten

Framework Detection Needed

Need to detect and support:

  • Nuxt: nuxt dev --host
  • Vite: vite --host
  • Next.js: Next binds to 0.0.0.0 by default, but may need SSL trust
  • Express/Fastify/etc: Custom server configurations

Success Criteria

  • User runs light init → interactive prompt to fix dev script
  • User runs bun dev → app accessible via https://app.lvh.me (no Error 500)
  • Dev server can make requests to https://api.lvh.me (mkcert CA trusted)
  • light dev wrapper command available as alternative
  • Clear documentation in troubleshooting guide

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/dockerDocker and containersdxDeveloper experience improvementsenhancementNew feature or requestpriority/highImportant for v1.0

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions