Skip to content

When basePath is defined, local/network URLs printed onInit are 404 #82882

@SethFalco

Description

@SethFalco

Link to the code that reproduces this issue

https://github.com/SethFalco/basepath-sandbox

To Reproduce

  1. Start the application in development (npm run dev)
  2. Visit the URL that's output in the terminal

Current vs. Expected behavior

I'd expect the URLs that are output from npm run dev to be the root of the SPA, not 404s.

Expected

$ npm run dev

> basepath-sandbox@0.1.0 dev
> next dev

   ▲ Next.js 15.5.0
   - Local:        http://localhost:3000/sfw
   - Network:      http://192.168.178.64:3000/sfw

Actual

$ npm run dev

> basepath-sandbox@0.1.0 dev
> next dev

   ▲ Next.js 15.5.0
   - Local:        http://localhost:3000
   - Network:      http://192.168.178.64:3000

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP PREEMPT_DYNAMIC Debian 6.12.27-1 (2025-05-06)
  Available memory (MB): 96204
  Available CPU cores: 22
Binaries:
  Node: 22.16.0
  npm: 11.5.2
  Yarn: 4.9.2
  pnpm: 10.6.5
Relevant Packages:
  next: 15.5.0 // Latest available version is detected (15.5.0).
  eslint-config-next: N/A
  react: 19.1.0
  react-dom: 19.1.0
  typescript: N/A
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Not sure

Which stage(s) are affected? (Select all that apply)

next dev (local)

Additional context

On the side, I'm also wondering if Next.js as a framework should redirect / to /basePath by default. This could ofc by overridden by developers if they define their own redirect with source='/'.

I'm personally configuring our project to do this:

  basePath: '/sfw',
  async redirects() {
    return [
      {
        source: '/',
        destination: '/sfw',
        basePath: false,
        permanent: false
      }
    ]
  },

As on production, / should never reach the webapp anyway, but during development, it's a nice convenience to have.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions