fix: make preview env optional
This commit is contained in:
4
env/schema.mjs
vendored
4
env/schema.mjs
vendored
@@ -10,8 +10,8 @@ export const serverSchema = z.object({
|
||||
CMS_API_KEY: z.string(),
|
||||
CMS_ENVIRONMENT: z.enum(["development", "production", "staging", "test"]),
|
||||
CMS_URL: z.string(),
|
||||
CMS_PREVIEW_URL: z.string(),
|
||||
CMS_PREVIEW_TOKEN: z.string(),
|
||||
CMS_PREVIEW_URL: z.string().optional(),
|
||||
CMS_PREVIEW_TOKEN: z.string().optional(),
|
||||
NODE_ENV: z.enum(["development", "test", "production"]),
|
||||
PRINT_QUERY: z.boolean().default(false),
|
||||
});
|
||||
|
||||
@@ -28,6 +28,10 @@ query GetCurrentBlockPage($locale: String!, $url: String!) {
|
||||
...Preamble
|
||||
title
|
||||
url
|
||||
system {
|
||||
uid
|
||||
content_type_uid
|
||||
}
|
||||
}
|
||||
total
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ export async function middleware(request: NextRequest) {
|
||||
searchParams.set("uri", pathNameWithoutLocale);
|
||||
|
||||
if (request.nextUrl.pathname.includes("preview")) {
|
||||
console.log("IN PREVIEW! Search params: ", request.nextUrl.searchParams);
|
||||
if (request.nextUrl.searchParams.get("hash")) {
|
||||
ContentstackLivePreview.setConfigFromParams(request.nextUrl.searchParams);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user