fix: patch @sveltejs/adapter-cloudflare
All checks were successful
deploy to cloudflare pages / deploy (push) Successful in 33s
All checks were successful
deploy to cloudflare pages / deploy (push) Successful in 33s
see https://github.com/sveltejs/kit/issues/12305
This commit is contained in:
parent
c2e36adc6a
commit
111b9c4ff0
3 changed files with 62 additions and 2 deletions
57
patches/@sveltejs%2Fadapter-cloudflare@4.7.4.patch
Normal file
57
patches/@sveltejs%2Fadapter-cloudflare@4.7.4.patch
Normal file
|
@ -0,0 +1,57 @@
|
|||
diff --git a/index.js b/index.js
|
||||
index 0fe55898e5697fc6a061299780e163ca4553cb05..e9fb7fea0082c7d3df7b07df21bd99cca6c4957c 100644
|
||||
--- a/index.js
|
||||
+++ b/index.js
|
||||
@@ -144,29 +144,33 @@ export default function (options = {}) {
|
||||
);
|
||||
}
|
||||
},
|
||||
- async emulate() {
|
||||
- const proxy = await getPlatformProxy(options.platformProxy);
|
||||
- const platform = /** @type {App.Platform} */ ({
|
||||
- env: proxy.env,
|
||||
- context: proxy.ctx,
|
||||
- caches: proxy.caches,
|
||||
- cf: proxy.cf
|
||||
- });
|
||||
+ emulate() {
|
||||
+ const getting_platform = (async () => {
|
||||
+ const proxy = await getPlatformProxy(options.platformProxy);
|
||||
+ const platform = /** @type {App.Platform} */ ({
|
||||
+ env: proxy.env,
|
||||
+ context: proxy.ctx,
|
||||
+ caches: proxy.caches,
|
||||
+ cf: proxy.cf
|
||||
+ });
|
||||
|
||||
- /** @type {Record<string, any>} */
|
||||
- const env = {};
|
||||
- const prerender_platform = /** @type {App.Platform} */ (/** @type {unknown} */ ({ env }));
|
||||
+ /** @type {Record<string, any>} */
|
||||
+ const env = {};
|
||||
+ const prerender_platform = /** @type {App.Platform} */ (/** @type {unknown} */ ({ env }));
|
||||
|
||||
- for (const key in proxy.env) {
|
||||
- Object.defineProperty(env, key, {
|
||||
- get: () => {
|
||||
- throw new Error(`Cannot access platform.env.${key} in a prerenderable route`);
|
||||
- }
|
||||
- });
|
||||
- }
|
||||
+ for (const key in proxy.env) {
|
||||
+ Object.defineProperty(env, key, {
|
||||
+ get: () => {
|
||||
+ throw new Error(`Cannot access platform.env.${key} in a prerenderable route`);
|
||||
+ }
|
||||
+ });
|
||||
+ }
|
||||
+ return { platform, prerender_platform };
|
||||
+ })();
|
||||
|
||||
return {
|
||||
- platform: ({ prerender }) => {
|
||||
+ platform: async ({ prerender }) => {
|
||||
+ const { platform, prerender_platform } = await getting_platform;
|
||||
return prerender ? prerender_platform : platform;
|
||||
}
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue