Fix new cache on Cloudflare (#29)

* Try with next.revalidate = 0

* Remove log

* Format
This commit is contained in:
Samy Pessé
2023-12-12 10:56:07 +01:00
committed by GitHub
parent b7a4721d66
commit ff8a343a54
2 changed files with 5 additions and 1 deletions
+4 -1
View File
@@ -68,7 +68,10 @@ export const getPublishedContentByUrl = cache(
secure: false,
format: 'json',
signal: signal,
cache: 'no-store',
// Cloudflare doesn't support the `cache` directive before next-on-pages patches the fetch function
// https://github.com/cloudflare/workerd/issues/698
// cache: 'no-store',
next: { revalidate: 0 },
});
return cacheResponse(response);
+1
View File
@@ -53,6 +53,7 @@ export async function middleware(request: NextRequest) {
console.log(`rendering ${resolved.space} ${resolved.pathname}`);
const headers = new Headers(request.headers);
headers.set('origin', inputURL.origin);
headers.set('x-gitbook-token', resolved.apiToken);
headers.set('x-gitbook-basepath', joinPath(proxyBasePath, resolved.basePath));
if (apiEndpoint) {