-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Output caching headers on RSC/prefetch responses (#2559)
- Loading branch information
Showing
7 changed files
with
96 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// @ts-ignore | ||
import nextOnPagesHandler from '@cloudflare/next-on-pages/fetch-handler'; | ||
|
||
import { withMiddlewareHeadersStorage } from './lib/middleware'; | ||
|
||
/** | ||
* We use a custom entrypoint until we can move to opennext (https://github.com/opennextjs/opennextjs-cloudflare/issues/92). | ||
* There is a bug in next-on-pages where headers can't be set on the response in the middleware for RSC requests (https://github.com/cloudflare/next-on-pages/issues/897). | ||
*/ | ||
export default { | ||
async fetch(request, env, ctx) { | ||
const response = await withMiddlewareHeadersStorage(() => | ||
nextOnPagesHandler.fetch(request, env, ctx), | ||
); | ||
|
||
return response; | ||
}, | ||
} as ExportedHandler<{ ASSETS: Fetcher }>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
diff --git a/dist/index.js b/dist/index.js | ||
index 32fec63484ec332eb291a7253e5e168223627535..653dee64794140bafe57219356c712b197c17530 100644 | ||
--- a/dist/index.js | ||
+++ b/dist/index.js | ||
@@ -6983,6 +6983,7 @@ async function buildWorkerFile({ vercelConfig, vercelOutput }, { | ||
outfile: outputFile, | ||
allowOverwrite: true, | ||
bundle: true, | ||
+ external: ["node:*", "cloudflare:*"], | ||
plugins: [ | ||
{ | ||
name: "custom-entrypoint-import-plugin", |