Skip to content

Cannot create first user with custom basePath set in dev mode #14707

@jefferyto

Description

@jefferyto

Describe the Bug

After following the reproduction steps and clicking on the "Create" button on the "Create first user" screen, Payload tries to send a POST request to http://localhost:3000/api/users/first-register (the default api route) instead of http://localhost:3000/payload/api/users/first-register (the api route for basePath set to "/payload"), leading to a 404 response.

Interestingly, this only occurs in dev mode. When running a production build, the correct api route for first-register is used and the user is created successfully.

Link to the code that reproduces this issue

https://github.com/jefferyto/payload-basepath-first-register

Reproduction Steps

  1. Checkout the reproduction repo (note that basePath is set to "/payload" in next.config.mjs), npm install, npm run dev
  2. Open http://localhost:3000/payload/admin in a browser
  3. Fill in the "Create first user" form and click the "Create" button

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

area: core

Environment Info

Binaries:
  Node: 22.21.1
  npm: 11.6.2
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  payload: 3.64.0
  next: 15.4.7
  @payloadcms/db-sqlite: 3.64.0
  @payloadcms/drizzle: 3.64.0
  @payloadcms/graphql: 3.64.0
  @payloadcms/next/utilities: 3.64.0
  @payloadcms/richtext-lexical: 3.64.0
  @payloadcms/translations: 3.64.0
  @payloadcms/ui/shared: 3.64.0
  react: 19.1.0
  react-dom: 19.1.0
Operating System:
  Platform: linux
  Arch: x64
  Version: #36-Ubuntu SMP PREEMPT_DYNAMIC Sat Oct 11 02:18:29 UTC 2025
  Available memory (MB): 7225
  Available CPU cores: 4

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions