Skip to content

Commit

Permalink
feat: disable inherit http_prxoy or https_proxy env
Browse files Browse the repository at this point in the history
  • Loading branch information
yjl9903 committed Oct 10, 2023
1 parent 1ba9838 commit b163d63
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
8 changes: 1 addition & 7 deletions packages/vite-plugin-cloudflare-functions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,20 +93,14 @@
"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": {
"optional": true
},
"ohmyfetch": {
"optional": true
},
"vite": {
"optional": true
},
"wrangler": {
"optional": true
}
},
"engines": {
Expand Down
9 changes: 8 additions & 1 deletion packages/vite-plugin-cloudflare-functions/src/vite/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
});

Expand Down
9 changes: 6 additions & 3 deletions playground/app/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,21 @@ 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 }
);
</script>

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

0 comments on commit b163d63

Please sign in to comment.