-
-
Notifications
You must be signed in to change notification settings - Fork 349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
custom pageContextJsonFileExtension #1960
Comments
I'd rather try to find a file extension that works for everyone. Is there some kind of standard file extension for dynamic JSON URLs? |
Can you share that patch? |
Can you elaborate? |
use this package to create patch: https://www.npmjs.com/package/patch-package
I don't think there is a standard extension name. I use the |
I use this the patch file: diff --git a/node_modules/vike/dist/esm/node/prerender/runPrerender.js b/node_modules/vike/dist/esm/node/prerender/runPrerender.js
index d49a91a..c5f380f 100644
--- a/node_modules/vike/dist/esm/node/prerender/runPrerender.js
+++ b/node_modules/vike/dist/esm/node/prerender/runPrerender.js
@@ -562,7 +562,7 @@ async function writeFiles({ urlOriginal, pageContext, htmlString, pageContextSer
write(urlOriginal, pageContext, '.html', htmlString, root, outDirClient, doNotCreateExtraDirectory, onPagePrerender, logLevel)
];
if (pageContextSerialized !== null) {
- writeJobs.push(write(urlOriginal, pageContext, '.pageContext.json', pageContextSerialized, root, outDirClient, doNotCreateExtraDirectory, onPagePrerender, logLevel));
+ writeJobs.push(write(urlOriginal, pageContext, '.pageContext.jsonx', pageContextSerialized, root, outDirClient, doNotCreateExtraDirectory, onPagePrerender, logLevel));
}
await Promise.all(writeJobs);
}
diff --git a/node_modules/vike/dist/esm/shared/getPageContextRequestUrl.js b/node_modules/vike/dist/esm/shared/getPageContextRequestUrl.js
index 72c1781..b164077 100644
--- a/node_modules/vike/dist/esm/shared/getPageContextRequestUrl.js
+++ b/node_modules/vike/dist/esm/shared/getPageContextRequestUrl.js
@@ -3,7 +3,7 @@ export { pageContextJsonFileExtension };
export { doNotCreateExtraDirectory };
// This module isn't loaded by the client-side of Server Routing => we don't inlcude `urlToFile` to `./utils.ts`
import { urlToFile } from '../utils/urlToFile.js';
-const pageContextJsonFileExtension = '.pageContext.json';
+const pageContextJsonFileExtension = '.pageContext.jsonx';
// `/some-base-url/index.pageContext.json` instead of `/some-base-url.pageContext.json` in order to comply to common reverse proxy setups, see https://github.com/vikejs/vike/issues/443
const doNotCreateExtraDirectory = false;
// See node/renderPage/handlePageContextRequestUrl.ts
|
As shown in the example in the figure, json is treated as a static resource, so the request will not go through the vike server and the result of the ssr request cannot be obtained. Therefore, we have to customize |
Thanks for sharing all that, that's helpful. So far, there doesn't seem to be a good solution for this. The main issue is that pre-rendered pages should actually generate a Let us first release the Related: #1629 |
Description
Some proxy servers will recognize json as a static resource.
But it is obvious that the ".pageContext.json" generated by vike is not a static resource.
In order to bypass the static resource rules of the proxy server, it would be great if the name can be customized.
At present, I use
patch-package
to change "xx.pageContext.json" to "xx.pageContext.jsonx".If the official can customize it, I will be very grateful.
The text was updated successfully, but these errors were encountered: