mirror of
https://github.com/angular/angular-cli.git
synced 2026-03-20 04:45:00 +00:00
Page:
1 x stories using corporate proxy
Pages
1 x angular cli
1 x build
1 x config
1 x doc
1 x e2e
1 x eject
1 x generate class
1 x generate component
1 x generate directive
1 x generate enum
1 x generate guard
1 x generate interface
1 x generate module
1 x generate pipe
1 x generate service
1 x generate
1 x home
1 x lint
1 x new
1 x serve
1 x stories 1.0 update
1 x stories application environments
1 x stories asset configuration
1 x stories autocompletion
1 x stories autoprefixer
1 x stories budgets
1 x stories code coverage
1 x stories configure hmr
1 x stories continuous integration
1 x stories css preprocessors
1 x stories disk serve
1 x stories github pages
1 x stories global lib
1 x stories global scripts
1 x stories global styles
1 x stories include angular flex
1 x stories include angular material
1 x stories include angularfire
1 x stories include bootstrap
1 x stories include font awesome
1 x stories internationalization
1 x stories linked library
1 x stories moving into the cli
1 x stories moving out of the cli
1 x stories multiple apps
1 x stories proxy
1 x stories routing
1 x stories third party lib
1 x stories universal rendering
1 x stories using corporate proxy
1 x stories
1 x test
1 x update
1 x xi18n
Home
Upgrading from Beta.10 to Beta.12
Upgrading from Beta.10 to Beta.14
add
angular cli
angular workspace
build
config
doc
e2e
eject
generate app shell
generate application
generate class
generate component
generate directive
generate enum
generate guard
generate interface
generate library
generate module
generate pipe
generate service
generate universal
generate
help
lint
new
run
serve
stories 1.0 update
stories app shell
stories application environments
stories asset configuration
stories autocompletion
stories autoprefixer
stories budgets
stories code coverage
stories configure hmr
stories continuous integration
stories create library
stories css preprocessors
stories disk serve
stories github pages
stories global lib
stories global scripts
stories global styles
stories include angular flex
stories include angular material
stories include angularfire
stories include bootstrap
stories include font awesome
stories internationalization
stories linked library
stories moving into the cli
stories moving out of the cli
stories multiple apps
stories multiple projects
stories proxy
stories rc update
stories rc.0 update
stories routing
stories third party lib
stories universal rendering
stories using corporate proxy
stories
test
update
version
xi18n
No results
1
1 x stories using corporate proxy
Hans Larsen edited this page 2018-05-03 13:12:11 -07:00
Table of Contents
Using corporate proxy
If you work behind a corporate proxy, the regular backend proxy configuration will not work if you try to proxy calls to any URL outside your local network.
In this case, you can configure the backend proxy to redirect calls through your corporate proxy using an agent:
npm install --save-dev https-proxy-agent
Then instead of using a proxy.conf.json file, we create a file called proxy.conf.js with the content
var HttpsProxyAgent = require('https-proxy-agent');
var proxyConfig = [{
context: '/api',
target: 'http://your-remote-server.com:3000',
secure: false
}];
function setupForCorporateProxy(proxyConfig) {
var proxyServer = process.env.http_proxy || process.env.HTTP_PROXY;
if (proxyServer) {
var agent = new HttpsProxyAgent(proxyServer);
console.log('Using corporate proxy server: ' + proxyServer);
proxyConfig.forEach(function(entry) {
entry.agent = agent;
});
}
return proxyConfig;
}
module.exports = setupForCorporateProxy(proxyConfig);
and edit the package.json file's start script accordingly
"start": "ng serve --proxy-config proxy.conf.js",
This way if you have a http_proxy or HTTP_PROXY environment variable defined, an agent will automatically be added to pass calls through your corporate proxy when running npm start.