Skip to content

Commit 0aac34d

Browse files
committed
refactor: use API_URL instead of PUBLIC_URL for Cloudflare cache purging
1 parent 6436058 commit 0aac34d

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/lib/cloudflare-cache.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function isCloudflareConfigured(): boolean {
1919
return !!(
2020
process.env.CLOUDFLARE_ZONE_ID &&
2121
process.env.CLOUDFLARE_API_TOKEN &&
22-
process.env.PUBLIC_URL
22+
process.env.API_URL
2323
);
2424
}
2525

@@ -99,16 +99,16 @@ export async function purgeCloudflareCache(urls: string[]): Promise<boolean> {
9999
* @param slug - The public note slug
100100
*/
101101
export async function purgePublicNoteCache(slug: string): Promise<boolean> {
102-
const publicUrl = process.env.PUBLIC_URL;
103-
if (!publicUrl) {
104-
logger.debug("[CLOUDFLARE] PUBLIC_URL not configured, skipping cache purge");
102+
const apiUrl = process.env.API_URL;
103+
if (!apiUrl) {
104+
logger.debug("[CLOUDFLARE] API_URL not configured, skipping cache purge");
105105
return true;
106106
}
107107

108108
// Purge both the API endpoint and any potential frontend route
109109
const urls = [
110-
`${publicUrl}/api/public-notes/${slug}`,
111-
`${publicUrl}/p/${slug}`, // Frontend route if exists
110+
`${apiUrl}/api/public-notes/${slug}`,
111+
`${apiUrl}/p/${slug}`, // Frontend route if exists
112112
];
113113

114114
return purgeCloudflareCache(urls);

0 commit comments

Comments
 (0)