-
Notifications
You must be signed in to change notification settings - Fork 56
Closed
Labels
Description
I'm submitting a...
[ ] Regression (a behavior that used to work and stopped working in a new release)
[X] Bug report
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Other... Please describe:
Expected Behavior
The ASK_CLI_PROXY environment variable should work for every SMAPI call made through ASK-CLI.
Current Behavior
The environment variable is completely ignored for most calls, as they go through the DefaultApiClient (ask-sdk-model-runtime\dist\index.js). A call that works with this variable is 'export-package,' which goes through clients\http-client.js.
This issue causes our corporate proxy to block the following calls:
1. ask smapi create-upload-url
2. ask smapi import-skill-package
3. ask smapi submit-skill-for-certification
Steps to Reproduce (for bugs)
Run 'ask smapi create-upload-url' as an example of a call that uses the DefaultApiClient.
Possible Solution
The following change to index.js allows the calls above to be made successfully in our environment[s]. If this approach could be made more robust, and was implemented into ask-cli, it'd be very helpful.
DefaultApiClient.prototype.invoke = function (request) {
var _this = this;
var urlObj = url.parse(request.url);
var urlPath = urlObj.protocol + '//' + urlObj.hostname + urlObj.path;
const proxyUrl = process.env.ASK_CLI_PROXY;
if (!!proxyUrl.trim()) {
var proxyHost = proxyUrl.substring(proxyUrl.indexOf('//') + 2, proxyUrl.lastIndexOf(':'));
var proxyPort = proxyUrl.substring(proxyUrl.lastIndexOf(':') + 1);
}
var headers = this.arrayToObjectHeader(request.headers);
if (!!proxyHost && !!proxyPort) {
headers['host'] = urlObj.hostname;
}
var clientRequestOptions = {
hostname: !!proxyHost ? proxyHost : urlObj.hostname,
port: !!proxyPort ? proxyPort : urlObj.port,
path: (!!proxyHost && !!proxyPort) ? urlPath : urlObj.path,
protocol: proxyHost === 'companyProxy (proxyHost)' ? 'http:' : urlObj.protocol, //an issue with localhost
auth: urlObj.auth,
headers: headers,
method: request.method,
};
var client = clientRequestOptions.protocol === 'https:' ? require('https') : require('http');
Your Environment and Context
- ask-cli version: 2.27.0
- Operating System and version: Windows 10 & Windows Server 2016, x64
- Node.js version used for development: 16.15.1
- NPM version used for development: 8.5.5
Reactions are currently unavailable