Skip to content

Commit b163d63

Browse files
committed
feat: disable inherit http_prxoy or https_proxy env
1 parent 1ba9838 commit b163d63

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

packages/vite-plugin-cloudflare-functions/package.json

+1-7
Original file line numberDiff line numberDiff line change
@@ -93,20 +93,14 @@
9393
"axios": "^1.5.0",
9494
"ohmyfetch": "^0.4.21",
9595
"vite": "^3.1.8 || ^4.0.0",
96-
"wrangler": "^2.20.1"
96+
"wrangler": "^2.20.1 || ^3.0.0"
9797
},
9898
"peerDependenciesMeta": {
9999
"axios": {
100100
"optional": true
101101
},
102102
"ohmyfetch": {
103103
"optional": true
104-
},
105-
"vite": {
106-
"optional": true
107-
},
108-
"wrangler": {
109-
"optional": true
110104
}
111105
},
112106
"engines": {

packages/vite-plugin-cloudflare-functions/src/vite/index.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,17 @@ export function CloudflarePagesFunctions(userConfig: UserConfig = {}): Plugin {
110110

111111
debug(command);
112112

113+
// Disable inherit http_prxoy or https_proxy env
114+
const wranglerEnv = { ...process.env };
115+
for (const key of ['HTTP_PROXY', 'HTTPS_PROXY', 'http_proxy', 'https_proxy']) {
116+
if (key in wranglerEnv) {
117+
delete wranglerEnv[key];
118+
}
119+
}
113120
wranglerProcess = spawn('npx', command, {
114121
shell: process.platform === 'win32',
115122
stdio: ['ignore', 'pipe', 'pipe'],
116-
env: process.env,
123+
env: wranglerEnv,
117124
cwd: path.dirname(functionsRoot)
118125
});
119126

playground/app/src/App.vue

+6-3
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,21 @@ const response = ref();
1717
watch(
1818
endpoint,
1919
async (endpoint) => {
20-
client.raw.get(`/api/${endpoint}`).then((resp) => {
20+
try {
21+
const resp = await client.raw.get(`/api/${endpoint}`);
2122
response.value = resp;
2223
message.value = resp.data;
23-
});
24+
} catch (error) {
25+
console.error(error);
26+
}
2427
},
2528
{ immediate: true }
2629
);
2730
</script>
2831

2932
<template>
3033
<div text-xl flex justify-center my8>
31-
<div space-y-4 max-w="80vw">
34+
<div space-y-4 max-w="80vw" min-w="60vw">
3235
<h1 text-2xl font-bold pb4 border="b-1 base">Vite Plugin Cloudflare Functions</h1>
3336
<div flex justify-start items-center>
3437
<span mr2 text-base-500>Endpoint:</span><span mr1 font-bold>/api/</span

0 commit comments

Comments
 (0)