-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add agent config for ng serve (#18323)
1. Add agent setting for the proxy config 2. Add https-proxy-agent package Signed-off-by: AllForNothing <[email protected]>
- Loading branch information
1 parent
1e38565
commit ec7c99c
Showing
6 changed files
with
57 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import HttpsProxyAgent from 'https-proxy-agent'; | ||
// Define the proxy configuration | ||
const HarborProxyConfig = [ | ||
{ | ||
"context": [ | ||
"/api", | ||
"/c", | ||
"/i18n", | ||
"/chartrepo", | ||
"/LICENSE", | ||
"/swagger.json", | ||
"/swagger2.json", | ||
"/devcenter-api-2.0", | ||
"/swagger-ui.bundle.js" | ||
], | ||
"target": "${A Harbor server}", | ||
"secure": false, | ||
"changeOrigin": true, | ||
"logLevel": "debug" | ||
} | ||
]; | ||
// Define if you use agent | ||
const useAgent = false; | ||
// Specify an agent server, if empty, will read it from environment variable http_proxy or HTTP_PROXY | ||
const specifiedAgentServer = "${An agent server}"; | ||
|
||
function setupForCorporateProxy(proxyConfig) { | ||
if (useAgent) { | ||
const agentServer = process.env.http_proxy || process.env.HTTP_PROXY || specifiedAgentServer; | ||
if (agentServer) { | ||
const agent = new HttpsProxyAgent(agentServer); | ||
console.log('Using corporate agent server: ' + agentServer); | ||
proxyConfig.forEach(function(entry) { | ||
entry.agent = agent; | ||
}); | ||
} | ||
} | ||
return proxyConfig; | ||
} | ||
|
||
export default setupForCorporateProxy(HarborProxyConfig); | ||
|
||
|