File tree Expand file tree Collapse file tree 4 files changed +29
-8
lines changed Expand file tree Collapse file tree 4 files changed +29
-8
lines changed Original file line number Diff line number Diff line change @@ -178,6 +178,8 @@ Variables required for GitHub Auth are:
178178
179179Solution supports HTTP Proxy settings when running in corporate environment. Simple set ` HTTP_PROXY ` environment variable.
180180
181+ For custom CA use environment variable ` CUSTOM_CA_PATH ` to load the certificate into proxy agent options.
182+
181183## Install Dependencies
182184
183185``` bash
Original file line number Diff line number Diff line change 11{
22 "name" : " copilot-metrics-viewer" ,
3- "version" : " 2.0.1 " ,
3+ "version" : " 2.0.2 " ,
44 "private" : true ,
55 "type" : " module" ,
66 "scripts" : {
Original file line number Diff line number Diff line change 1- import { ProxyAgent , setGlobalDispatcher } from "undici" ;
2- import { ofetch } from "ofetch" ;
1+ import { ProxyAgent , setGlobalDispatcher } from 'undici' ;
2+ import { ofetch } from 'ofetch' ;
3+ import { readFileSync } from 'fs' ;
34
45export default defineNitroPlugin ( ( nitro ) => {
56 if ( process . env . HTTP_PROXY ) {
6- const proxyAgent = new ProxyAgent ( process . env . HTTP_PROXY ) ;
7+ const tlsOptions = process . env . CUSTOM_CA_PATH ? {
8+ tls : {
9+ ca : [
10+ readFileSync ( process . env . CUSTOM_CA_PATH )
11+ ]
12+ }
13+ } : { } ;
14+
15+ const proxyAgent = new ProxyAgent ( {
16+ uri : process . env . HTTP_PROXY ,
17+ ...tlsOptions
18+ } ) ;
19+
720 setGlobalDispatcher ( proxyAgent ) ;
8- const fetchWithProxy = ofetch . create ( { dispatcher : proxyAgent } ) ;
9- nitro . hooks . hook ( "request" , ( context ) => {
21+
22+ const fetchWithProxy = ofetch . create ( {
23+ dispatcher : proxyAgent ,
24+ httpsProxy : process . env . HTTP_PROXY ,
25+ proxy : false
26+ } ) ;
27+
28+ nitro . hooks . hook ( 'request' , ( context ) => {
1029 context . fetch = fetchWithProxy ;
1130 } ) ;
1231 }
13- } ) ;
32+ } ) ;
You can’t perform that action at this time.
0 commit comments