Closed
Description
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:
- create blank payload project and upgrade to latest version.
- move files inside admin folder to the root path, and set payload config
routes:{ admin:`/` }
- add localization settings in payload config
- create a sample collection, and set one of the field localized. Then create a sample document.
- Enter the edit view of the document you just created, click Copy to Locale from the 3-dot next to Save button
- 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