diff --git a/packages/vite-plugin-cloudflare-functions/package.json b/packages/vite-plugin-cloudflare-functions/package.json index 828f3ce1..e5f9ae8c 100644 --- a/packages/vite-plugin-cloudflare-functions/package.json +++ b/packages/vite-plugin-cloudflare-functions/package.json @@ -93,7 +93,7 @@ "axios": "^1.5.0", "ohmyfetch": "^0.4.21", "vite": "^3.1.8 || ^4.0.0", - "wrangler": "^2.20.1" + "wrangler": "^2.20.1 || ^3.0.0" }, "peerDependenciesMeta": { "axios": { @@ -101,12 +101,6 @@ }, "ohmyfetch": { "optional": true - }, - "vite": { - "optional": true - }, - "wrangler": { - "optional": true } }, "engines": { diff --git a/packages/vite-plugin-cloudflare-functions/src/vite/index.ts b/packages/vite-plugin-cloudflare-functions/src/vite/index.ts index 2a455eea..c64b23e6 100644 --- a/packages/vite-plugin-cloudflare-functions/src/vite/index.ts +++ b/packages/vite-plugin-cloudflare-functions/src/vite/index.ts @@ -110,10 +110,17 @@ export function CloudflarePagesFunctions(userConfig: UserConfig = {}): Plugin { debug(command); + // Disable inherit http_prxoy or https_proxy env + const wranglerEnv = { ...process.env }; + for (const key of ['HTTP_PROXY', 'HTTPS_PROXY', 'http_proxy', 'https_proxy']) { + if (key in wranglerEnv) { + delete wranglerEnv[key]; + } + } wranglerProcess = spawn('npx', command, { shell: process.platform === 'win32', stdio: ['ignore', 'pipe', 'pipe'], - env: process.env, + env: wranglerEnv, cwd: path.dirname(functionsRoot) }); diff --git a/playground/app/src/App.vue b/playground/app/src/App.vue index 4bd7fe9a..04c0ced0 100644 --- a/playground/app/src/App.vue +++ b/playground/app/src/App.vue @@ -17,10 +17,13 @@ const response = ref(); watch( endpoint, async (endpoint) => { - client.raw.get(`/api/${endpoint}`).then((resp) => { + try { + const resp = await client.raw.get(`/api/${endpoint}`); response.value = resp; message.value = resp.data; - }); + } catch (error) { + console.error(error); + } }, { immediate: true } ); @@ -28,7 +31,7 @@ watch(