diff --git a/app/api/web/revalidate/route.ts b/app/api/web/revalidate/route.ts index df022b91a..42baad8d6 100644 --- a/app/api/web/revalidate/route.ts +++ b/app/api/web/revalidate/route.ts @@ -29,6 +29,7 @@ const validateJsonBody = z.object({ }) .optional(), locale: z.nativeEnum(Lang), + publish_details: z.object({ locale: z.nativeEnum(Lang) }).optional(), uid: z.string(), url: z.string().optional(), page_settings: z @@ -67,15 +68,19 @@ export async function POST(request: NextRequest) { data: { content_type, entry }, }, } = validatedData - const refsTag = generateRefsResponseTag(entry.locale, entry.uid) - const refTag = generateRefTag(entry.locale, content_type.uid, entry.uid) - const tag = generateTag(entry.locale, entry.uid) + + // The publish_details.locale is the locale that the entry is published in, regardless if it is "localized" or not + const entryLocale = entry.publish_details?.locale ?? entry.locale + + const refsTag = generateRefsResponseTag(entryLocale, entry.uid) + const refTag = generateRefTag(entryLocale, content_type.uid, entry.uid) + const tag = generateTag(entryLocale, entry.uid) const languageSwitcherTag = generateTag( - entry.locale, + entryLocale, entry.uid, languageSwitcherAffix ) - const metadataTag = generateTag(entry.locale, entry.uid, metadataAffix) + const metadataTag = generateTag(entryLocale, entry.uid, metadataAffix) console.info(`Revalidating refsTag: ${refsTag}`) revalidateTag(refsTag) @@ -94,12 +99,12 @@ export async function POST(request: NextRequest) { if (entry.breadcrumbs) { const breadcrumbsRefsTag = generateRefsResponseTag( - entry.locale, + entryLocale, entry.uid, breadcrumbsAffix ) const breadcrumbsTag = generateTag( - entry.locale, + entryLocale, entry.uid, breadcrumbsAffix ) @@ -113,7 +118,7 @@ export async function POST(request: NextRequest) { if (entry.page_settings?.hide_booking_widget) { const bookingwidgetTag = generateTag( - entry.locale, + entryLocale, entry.uid, bookingwidgetAffix )