Azure / static-web-apps-cli

Azure Static Web Apps CLI ✨
https://aka.ms/swa/cli-local-development
MIT License
585 stars 112 forks source link

Support proxy setting on Static Web Apps CLI. #685

Open komayama opened 1 year ago

komayama commented 1 year ago

Requests

Please could you support proxy setting on SWA CLI like function core tools setting?

Troubleshooting

We experienced the following error message even put exact staticwebapp.config.json location.

[swa] WARNING: Failed to load staticwebapp.config.json schema. Continuing without validation!

We investigated the warning that is output when the swa start command is executed in the customer's environment is described on line 108 of the source code below. In addition, when we checked the conditions under which the warning is output, we found that the warning is output when the value is null in the variable schema, which stores the execution result of the loadSWAConfigSchemema method. https://github.com/Azure/static-web-apps-cli/blob/a036c97570bed24bfc3d10de39f075fd0822b353/src/core/utils/user-config.ts#L108 image

We were concerned that the loadSWAConfigSchemema method was not acquiring values, so we subsequently checked the processing of the loadSWAConfigSchemema method. According to the processing performed in the source code below, the loadSWAConfigSchemema method attempts to obtain configuration information from the endpoint "" https://json.schemastore.org/staticwebapp.config.json" and converts it to json format if it is obtained. If not, it returns null. When the swa start command was executed in the customer's environment, null was returned in the loadSWAConfigSchemema method, so it is possible that communication to the endpoint was not established.

https://github.com/Azure/static-web-apps-cli/blob/a036c97570bed24bfc3d10de39f075fd0822b353/src/core/utils/user-config.ts#L167 image

We checked how to use their network environment on his local PC. So we checked to use curl command that connect the target url or not. The following results, they are using Proxy on their environment.

local PC ---> Proxy (Zscaler) ---> network ---> staticwebapp.config.json

PS C:\xxxxx\xxxxx\xxxxx\angular-pj> curl.exe -I https://json.schemastore.org/staticwebapp.config.json
HTTP/1.1 200 Connection Established
Proxy-Agent: Zscaler/6.2

HTTP/1.1 200 OK
Content-Length: 22606
Connection: close
Content-Type: application/json; charset=utf-8
Date: Thu, 23 Mar 2023 06:28:54 GMT
Server: Microsoft-IIS/10.0
Accept-Ranges: bytes
Access-Control-Allow-Origin: *
Cache-Control: public,max-age=31536000
ETag: "1cf32b1183bd91:0"
Last-Modified: Tue, 07 Feb 2023 17:22:01 GMT
Vary: Accept-Encoding, If-Modified-Since
Content-Security-Policy: object-src 'none';
Arr-Disable-Session-Affinity: True
aaddiill2018 commented 4 months ago

Hey, i am still getting this with bitbucket pipeline:

Deploying to environment: production ✖ Failed to load staticwebapp.config.json schema. Continuing without validation!

Anyone has a solution?