aws4
aws4 copied to clipboard
Signature not match when try to request throught proxy url
I use aws4 to sign my request to send to dynamodb service It works when I use a simple dynamodb URL but its not work when I replace the host with my proxy URL Do you have any idea on how we can sign requests and use proxy as hostname? here's the example code
let payload = { "TableName":"simple-tablename" ....};
let option = {
host:"${hostname}",
service: 'dynamodb',
region: 'ap-southeast-1',
path: '/',
method: 'POST',
headers: {
'Content-Type': 'application/x-amz-json-1.0',
'X-Amz-Target': 'DynamoDB_20120810.UpdateItem'
},
body: JSON.stringify(payload)
};
AWS4.sign(option, {
accessKeyId: AWS.config.credentials?.accessKeyId,
secretAccessKey: AWS.config.credentials?.secretAccessKey,
sessionToken: AWS.config.credentials?.sessionToken
});
const req = https.request(option, (res) => {
console.log('statusCode: ' + res.statusCode);
res.on('data', d => {
const resObj = JSON.parse(d.toString());
console.log(resObj);
});
});
req.on('error', (error) => {
console.error('error : ' + error);
});
req.write(data);
req.end();
}
Its work when ${hostname} = 'dynamodb.ap-southeast-1.amazonaws.com' but not work when I use my proxy URL Any help would be appreciated, perhaps I am missing something simple?