Skip to content

PayloadCMS 3.68.3 breaks admin UI when serverURL is set #14900

Description

@hai-trung-le

Describe the Bug

b82356b updates all calls to formatAdminURL() to pass in config.serverURL. When I set serverURL: "http://localhost:3000", run npm run dev and go to http://localhost:3000/admin, I get the error

 ⨯ [TypeError: Invalid URL] {
  code: 'ERR_INVALID_URL',
  input: 'http://localhost:3000http://localhost:3000/admin',
  digest: '185251315'
}
[12:26:08] ERROR: Failed to create URL object from URL: http://localhost:3000http://localhost:3000/admin, falling back to http://localhost:3000http://localhost:3000/admin

It seems the function formatAdminURL() is also being used to get the path of routes, not just the absolute URL, so the commit breaks all of those cases if serverURL is set:

const currentRoute = formatAdminURL({
adminRoute,
path: Array.isArray(params.segments) ? `/${params.segments.join('/')}` : null,
serverURL: config.serverURL,
})

Here, currentRoute is supposed to be the admin route, e.g., "/admin", but by passing in a set serverURL, it is now "http://localhost:3000/admin". Later on, in the same component:

overrides: {
fallbackLocale: false,
req: {
query: qs.parse(queryString, {
depth: 10,
ignoreQueryPrefix: true,
}),
},
urlSuffix: `${currentRoute}${searchParams ? queryString : ''}`,

urlSuffix is now "http://localhost:3000/admin", and this breaks createLocalReq(), which basically tries to construct the URL `http://localhost:3000http://localhost:3000/admin"

const urlToUse =
req?.url || req.payload?.config?.serverURL
? `${req.payload?.config.serverURL}${urlSuffix || ''}`
: fallbackURL

Link to the code that reproduces this issue

N/A

Reproduction Steps

Which area(s) are affected?

area: core

Environment Info

Relevant Packages:
  payload: 3.68.3
  next: 15.5.9
  @payloadcms/db-postgres: 3.68.3
  @payloadcms/drizzle: 3.68.3
  @payloadcms/graphql: 3.68.3
  @payloadcms/next/utilities: 3.68.3      
  @payloadcms/plugin-cloud-storage: 3.68.3
  @payloadcms/storage-s3: 3.68.3
  @payloadcms/translations: 3.68.3       
  @payloadcms/ui/shared: 3.68.3
  react: 19.2.1
  react-dom: 19.2.1
Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 10 Pro

Activity

  1. added
    status: needs-triage
    validate-reproduction
    on Dec 12, 2025
  2. added
    area: core
    and removed
    validate-reproduction
    on Dec 12, 2025
  3. github-actions commented on Dec 12, 2025

    @github-actions
    Contributor

    Please add a reproduction in order for us to be able to investigate.

    Depending on the quality of reproduction steps, this issue may be closed if no reproduction is provided.

    Why was this issue marked with the invalid-reproduction label?

    To be able to investigate, we need access to a reproduction to identify what triggered the issue. We prefer a link to a public GitHub repository created with create-payload-app@latest -t blank or a forked/branched version of this repository with tests added (more info in the reproduction-guide).

    To make sure the issue is resolved as quickly as possible, please make sure that the reproduction is as minimal as possible. This means that you should remove unnecessary code, files, and dependencies that do not contribute to the issue. Ensure your reproduction does not depend on secrets, 3rd party registries, private dependencies, or any other data that cannot be made public. Avoid a reproduction including a whole monorepo (unless relevant to the issue). The easier it is to reproduce the issue, the quicker we can help.

    Please test your reproduction against the latest version of Payload to make sure your issue has not already been fixed.

    I added a link, why was it still marked?

    Ensure the link is pointing to a codebase that is accessible (e.g. not a private repository). "example.com", "n/a", "will add later", etc. are not acceptable links -- we need to see a public codebase. See the above section for accepted links.

    Useful Resources

  4. geminigeek commented on Dec 13, 2025

    @geminigeek
    Contributor

    same issue, remove serverURL it works

  5. removed
    status: needs-triage
    on Dec 14, 2025
  6. github-actions commented on Dec 14, 2025

    @github-actions
    Contributor

    🚀 This is included in version v3.68.4

  7. hai-trung-le commented on Dec 15, 2025

    @hai-trung-le
    Author

    It is still broken on v3.68.4, now going to http://localhost:3000/admin/login lead to an infinite redirect loop to itself.

    if (
    !permissions.canAccessAdmin &&
    !isPublicAdminRoute({ adminRoute, config: payload.config, route: currentRoute }) &&
    !isCustomAdminView({ adminRoute, config: payload.config, route: currentRoute })
    ) {

    The Root component checks if the route is a public admin route to redirect if not, but currentRoute is now an absolute URL, which breaks isPublicAdminRoute(), which assumes a relative route.

    I feel we should revert b82356b and redo it in a more systematic way, because formatAdminURL() is doing three tasks at once: getting the absolute URL, getting the root relative URL (relative to origin), and getting the local relative URL (relative to base URL). Conflating them into one function is just inherently buggy.

  8. jtimi-mtbk commented on Dec 15, 2025

    @jtimi-mtbk

    @hai-trung-le correct
    I still reproduce issue at: #14918
    @denolfe please help us check it.

  9. DanRibbens commented on Dec 15, 2025

    @DanRibbens
    Contributor

    @jtimi-mtbk it is currently Sunday 11 PM for most of the team. We will fix and release another patch tomorrow.
    I'm really sorry this has been an issue for everyone. I've proposed a way forward for the team to address in the morning.

  10. added
    status: needs-triage
    on Dec 15, 2025
  11. removed
    area: core
    on Dec 15, 2025
  12. removed
    status: needs-triage
    on Dec 15, 2025
  13. github-actions commented on Dec 15, 2025

    @github-actions
    Contributor

    🚀 This is included in version v3.68.5

  14. jtimi-mtbk commented on Dec 16, 2025

    @jtimi-mtbk

    @DanRibbens Thank you to the team for the quick fix. I really appreciate everyone's effort. 🎉

  15. github-actions commented on Dec 23, 2025

    @github-actions
    Contributor

    This issue has been automatically locked.
    Please open a new issue if this issue persists with any additional detail.

  16. locked as resolved and limited conversation to collaborators on Dec 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions