Skip to content

"Copy to locale" redirect incorrectly when admin route is "/" #12558

Closed
@anyuj

Description

@anyuj

Describe the Bug

When you set admin route as "/" and enable localization, once you create a document in one locale and try to copy to another locale, it will redirect to http://collections/{sampleCollectionSlug}/{documentID}?locale={toLocale}, which doesn't work because it does not include the serverURL.

Here is my PR #12560, it uses payload's formatAdminURL helper function to form the redirect URL appropriately.

Link to the code that reproduces this issue

https://github.com/anyuj/wrong-redirect-route-for-copy-locale

Reproduction Steps

Use above repo or:

  1. create blank payload project and upgrade to latest version.
  2. move files inside admin folder to the root path, and set payload config routes:{ admin:`/` }
  3. add localization settings in payload config
  4. create a sample collection, and set one of the field localized. Then create a sample document.
  5. Enter the edit view of the document you just created, click Copy to Locale from the 3-dot next to Save button
  6. Then you will see it will be falsely direct to "http://collections/{sampleCollectionSlug}/{documentID}?locale={toLocale}"

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

area: core

Environment Info

Payload: 3.39.1
Next.js: 15.3.2
Node: ^22

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions