Skip to content

Commit

Permalink
fix revalidate page cache not work
Browse files Browse the repository at this point in the history
  • Loading branch information
kahlstrm committed Jan 18, 2024
1 parent cfc41e6 commit 15f603d
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 10 deletions.
18 changes: 10 additions & 8 deletions apps/cms/src/hooks/revalidate-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,17 @@ export const revalidatePage =
const revalidate = async (): Promise<void> => {
try {
const fetchData = JSON.stringify(await getFetchData(doc, req));
const res = await fetch(
`${
process.env.PUBLIC_FRONTEND_URL
}/api/revalidate?${new URLSearchParams({
secret: process.env.PAYLOAD_REVALIDATION_KEY ?? "",
collection,
fetchData,
}).toString()}`,
const fetchUrl = `${
process.env.PUBLIC_FRONTEND_URL
}/next_api/revalidate?${new URLSearchParams({
secret: process.env.PAYLOAD_REVALIDATION_KEY ?? "",
collection,
fetchData,
}).toString()}`;
req.payload.logger.info(
`sending revalidate request ${fetchUrl.replace(process.env.PAYLOAD_REVALIDATION_KEY ?? "", "REDACTED")}`,
);
const res = await fetch(fetchUrl);
if (res.ok) {
req.payload.logger.info(
`Revalidated collection ${collection} with data ${fetchData}`,
Expand Down
2 changes: 1 addition & 1 deletion apps/cms/src/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ import type { GeneratePreviewURL } from "payload/config";
export const generatePreviewUrl =
<T>(getUrl: (doc: T) => string): GeneratePreviewURL =>
(doc) =>
`${process.env.PUBLIC_FRONTEND_URL}/api/preview?url=${getUrl(doc as T)}`;
`${process.env.PUBLIC_FRONTEND_URL}/next_api/preview?url=${getUrl(doc as T)}`;
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion apps/web/src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ export function middleware(request: NextRequest): NextResponse {
);
}
export const config = {
matcher: ["/((?!_next|fi|en).*)"],
matcher: ["/((?!_next|fi|en|next_api).*)"],
};

0 comments on commit 15f603d

Please sign in to comment.