Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

fix cf headers (#38824)

Francesco Sansalvadore5098786f08f9
diff --git a/apps/www/app/api-v2/cms-posts/route.ts b/apps/www/app/api-v2/cms-posts/route.ts
index 9df5606bde0..1750cd44c62 100644
--- a/apps/www/app/api-v2/cms-posts/route.ts
+++ b/apps/www/app/api-v2/cms-posts/route.ts
@@ -9,6 +9,9 @@ export const runtime = 'edge'
const corsHeaders = {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Headers': 'authorization, x-client-info, apikey, content-type',
+}
+
+const cfHeaders = {
'CF-Access-Client-Id': process.env.CF_ACCESS_CLIENT_ID ?? '',
'CF-Access-Client-Secret': process.env.CF_ACCESS_CLIENT_SECRET ?? '',
}
@@ -160,6 +163,7 @@ export async function GET(request: NextRequest) {
headers: {
'Content-Type': 'application/json',
...(apiKey ? { Authorization: `Bearer ${apiKey}` } : {}),
+ ...cfHeaders,
},
cache: 'no-store',
})
@@ -251,6 +255,7 @@ export async function GET(request: NextRequest) {
headers: {
'Content-Type': 'application/json',
...(apiKey ? { Authorization: `Bearer ${apiKey}` } : {}),
+ ...cfHeaders,
},
cache: 'no-store', // Never cache draft content
})
@@ -330,6 +335,7 @@ export async function GET(request: NextRequest) {
headers: {
'Content-Type': 'application/json',
...(apiKey ? { Authorization: `Bearer ${apiKey}` } : {}),
+ ...cfHeaders,
},
cache: 'no-store',
})
@@ -410,6 +416,7 @@ export async function GET(request: NextRequest) {
headers: {
'Content-Type': 'application/json',
...(apiKey ? { Authorization: `Bearer ${apiKey}` } : {}),
+ ...cfHeaders,
},
// For published posts: allow caching with revalidation
next: { revalidate: 60 }, // 1 minute
@@ -504,6 +511,7 @@ export async function GET(request: NextRequest) {
headers: {
'Content-Type': 'application/json',
...(apiKey ? { Authorization: `Bearer ${apiKey}` } : {}),
+ ...cfHeaders,
},
next: { revalidate: 60 }, // 1 minute for published posts
})
@@ -525,6 +533,7 @@ export async function GET(request: NextRequest) {
headers: {
'Content-Type': 'application/json',
...(apiKey ? { Authorization: `Bearer ${apiKey}` } : {}),
+ ...cfHeaders,
},
next: { revalidate: 60 }, // 1 minute for published posts
})
@@ -618,6 +627,7 @@ export async function GET(request: NextRequest) {
headers: {
'Content-Type': 'application/json',
...(apiKey ? { Authorization: `Bearer ${apiKey}` } : {}),
+ ...cfHeaders,
},
// For individual post requests, don't cache to ensure fresh data
cache: slug ? 'no-store' : 'default',