Erste brauchbare Version
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
import config from '@payload-config';
|
||||
import { REST_DELETE, REST_GET, REST_OPTIONS, REST_PATCH, REST_POST, REST_PUT } from '@payloadcms/next/routes';
|
||||
import '@payloadcms/next/css';
|
||||
|
||||
export const GET = REST_GET(config);
|
||||
export const POST = REST_POST(config);
|
||||
export const DELETE = REST_DELETE(config);
|
||||
export const PATCH = REST_PATCH(config);
|
||||
export const PUT = REST_PUT(config);
|
||||
export const OPTIONS = REST_OPTIONS(config);
|
||||
@@ -0,0 +1,35 @@
|
||||
import { draftMode } from 'next/headers';
|
||||
import { redirect } from 'next/navigation';
|
||||
import { getPayload } from 'payload';
|
||||
import config from '@payload-config';
|
||||
|
||||
export async function GET(request: Request) {
|
||||
const { searchParams } = new URL(request.url);
|
||||
|
||||
const slug = searchParams.get('slug');
|
||||
|
||||
if (!slug)
|
||||
return new Response('Missing slug', {
|
||||
status: 400
|
||||
});
|
||||
|
||||
const payload = await getPayload({
|
||||
config
|
||||
});
|
||||
|
||||
const { user } = await payload.auth({
|
||||
headers: request.headers
|
||||
});
|
||||
|
||||
if (!user)
|
||||
return new Response('Unauthorized', {
|
||||
status: 401
|
||||
});
|
||||
|
||||
const draft = await draftMode();
|
||||
|
||||
draft.enable();
|
||||
|
||||
// redirect(`/${slug}`);
|
||||
redirect('/');
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import config from '@payload-config';
|
||||
import { GRAPHQL_PLAYGROUND_GET } from '@payloadcms/next/routes';
|
||||
import '@payloadcms/next/css';
|
||||
|
||||
export const GET = GRAPHQL_PLAYGROUND_GET(config);
|
||||
@@ -0,0 +1,5 @@
|
||||
import config from '@payload-config';
|
||||
import { GRAPHQL_POST, REST_OPTIONS } from '@payloadcms/next/routes';
|
||||
|
||||
export const POST = GRAPHQL_POST(config);
|
||||
export const OPTIONS = REST_OPTIONS(config);
|
||||
Reference in New Issue
Block a user