Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Signature not match when try to request throught proxy url #138

Open
kittipongpad opened this issue Sep 27, 2021 · 0 comments
Open

Signature not match when try to request throught proxy url #138

kittipongpad opened this issue Sep 27, 2021 · 0 comments

Comments

@kittipongpad
Copy link

kittipongpad commented Sep 27, 2021

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant