Similar to #9746. When deploying to Vercel, preview deployment URLs are dynamically generated. This breaks `admin.preview` within those deployments because there is no mechanism by which we can detect and set that URL within Payload. Although Vercel provides various environment variables at our disposal, they provide no concrete identifier for exactly which URL is being currently previewed (you can access the same deployment from a number of different URLs). The fix is to support relative `admin.preview` URLs, that way Payload can prepend the application's top-level domain dynamically at render-time in order to create a fully qualified URL. So when you visit a Vercel preview deployment, for example, that deployment's unique URL is used as the preview redirect, instead of the application's root/production domain. Note: this does not fix multi-tenancy single-domain setups, as those still require a static top-level domain for each tenant.
89 lines
1.8 KiB
TypeScript
89 lines
1.8 KiB
TypeScript
import type { CollectionConfig } from 'payload'
|
|
|
|
import { Archive } from '../blocks/ArchiveBlock/index.js'
|
|
import { CallToAction } from '../blocks/CallToAction/index.js'
|
|
import { Content } from '../blocks/Content/index.js'
|
|
import { MediaBlock } from '../blocks/MediaBlock/index.js'
|
|
import { hero } from '../fields/hero.js'
|
|
import { mediaSlug, ssrPagesSlug, tenantsSlug } from '../shared.js'
|
|
|
|
export const SSR: CollectionConfig = {
|
|
slug: ssrPagesSlug,
|
|
labels: {
|
|
singular: 'SSR Page',
|
|
plural: 'SSR Pages',
|
|
},
|
|
access: {
|
|
read: () => true,
|
|
create: () => true,
|
|
update: () => true,
|
|
delete: () => true,
|
|
},
|
|
admin: {
|
|
useAsTitle: 'title',
|
|
defaultColumns: ['id', 'title', 'slug', 'createdAt'],
|
|
preview: (doc) => `/live-preview/ssr/${doc?.slug}`,
|
|
},
|
|
fields: [
|
|
{
|
|
name: 'slug',
|
|
type: 'text',
|
|
required: true,
|
|
admin: {
|
|
position: 'sidebar',
|
|
},
|
|
},
|
|
{
|
|
name: 'tenant',
|
|
type: 'relationship',
|
|
relationTo: tenantsSlug,
|
|
admin: {
|
|
position: 'sidebar',
|
|
},
|
|
},
|
|
{
|
|
name: 'title',
|
|
type: 'text',
|
|
required: true,
|
|
},
|
|
{
|
|
type: 'tabs',
|
|
tabs: [
|
|
{
|
|
label: 'Hero',
|
|
fields: [hero],
|
|
},
|
|
{
|
|
label: 'Content',
|
|
fields: [
|
|
{
|
|
name: 'layout',
|
|
type: 'blocks',
|
|
blocks: [CallToAction, Content, MediaBlock, Archive],
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
{
|
|
name: 'meta',
|
|
type: 'group',
|
|
fields: [
|
|
{
|
|
name: 'title',
|
|
type: 'text',
|
|
},
|
|
{
|
|
name: 'description',
|
|
type: 'textarea',
|
|
},
|
|
{
|
|
name: 'image',
|
|
type: 'upload',
|
|
relationTo: mediaSlug,
|
|
},
|
|
],
|
|
},
|
|
],
|
|
}
|