### What? Fixes #12811 ### Why? Custom Views become unreachable when admin route is set to "/" because the forward slash of the current route gets removed before routing to custom view ### How? Fixes # --> Fixes #12811 Custom Views become unreachable when admin route is set to "/" because the forward slash of the current route gets removed before routing to custom view --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1210582760545830 --------- Co-authored-by: Jacob Fletcher <jacobsfletch@gmail.com>
59 lines
1.4 KiB
TypeScript
59 lines
1.4 KiB
TypeScript
import { fileURLToPath } from 'node:url'
|
|
import path from 'path'
|
|
|
|
import { buildConfigWithDefaults } from '../buildConfigWithDefaults.js'
|
|
import { devUser } from '../credentials.js'
|
|
import { PostsCollection, postsSlug } from './collections/Posts/index.js'
|
|
import { MenuGlobal } from './globals/Menu/index.js'
|
|
import { adminRoute } from './shared.js'
|
|
|
|
const filename = fileURLToPath(import.meta.url)
|
|
const dirname = path.dirname(filename)
|
|
|
|
export default buildConfigWithDefaults({
|
|
collections: [PostsCollection],
|
|
admin: {
|
|
autoLogin: {
|
|
email: devUser.email,
|
|
password: devUser.password,
|
|
prefillOnly: true,
|
|
},
|
|
importMap: {
|
|
baseDir: path.resolve(dirname),
|
|
},
|
|
theme: 'dark',
|
|
components: {
|
|
views: {
|
|
CustomDefaultView: {
|
|
Component: '/CustomView/index.js#CustomView',
|
|
path: '/custom-view',
|
|
},
|
|
},
|
|
},
|
|
},
|
|
cors: ['http://localhost:3000', 'http://localhost:3001'],
|
|
globals: [MenuGlobal],
|
|
routes: {
|
|
admin: adminRoute,
|
|
},
|
|
onInit: async (payload) => {
|
|
await payload.create({
|
|
collection: 'users',
|
|
data: {
|
|
email: devUser.email,
|
|
password: devUser.password,
|
|
},
|
|
})
|
|
|
|
await payload.create({
|
|
collection: postsSlug,
|
|
data: {
|
|
text: 'example post',
|
|
},
|
|
})
|
|
},
|
|
typescript: {
|
|
outputFile: path.resolve(dirname, 'payload-types.ts'),
|
|
},
|
|
})
|