## Description Fixes issue where the `basePath` from the `next-config` was not respected for the `logout` button link - [x] I have read and understand the [CONTRIBUTING.md](https://github.com/payloadcms/payload/blob/main/CONTRIBUTING.md) document in this repository. ## Type of change - [x] Bug fix (non-breaking change which fixes an issue) ## Checklist: - [x] Existing test suite passes locally with my changes
24 lines
628 B
TypeScript
24 lines
628 B
TypeScript
import type { Config } from 'payload'
|
|
|
|
/** Will read the `routes.admin` config and appropriately handle `"/"` admin paths */
|
|
export const formatAdminURL = (args: {
|
|
adminRoute: Config['routes']['admin']
|
|
basePath?: string
|
|
path: string
|
|
serverURL?: Config['serverURL']
|
|
}): string => {
|
|
const { adminRoute, basePath = '', path, serverURL } = args
|
|
|
|
if (adminRoute) {
|
|
if (adminRoute === '/') {
|
|
if (!path) {
|
|
return `${serverURL || ''}${basePath}${adminRoute}`
|
|
}
|
|
} else {
|
|
return `${serverURL || ''}${basePath}${adminRoute}${path}`
|
|
}
|
|
}
|
|
|
|
return `${serverURL || ''}${basePath}${path}`
|
|
}
|