Open ekkis opened 2 years ago
Hey @ekkis, I also had a similar issue. I fixed the issue by giving host
, path
to the requestOptions
of the sign
function.
const signedHeaders = sign(
{
method: 'GET',
service: 'service',
region: 'eu-central-1',
host: 'https://zzzzzzzzzz.service.eu-central-1.amazonaws.com',
path: '/dev/v1/test?' + searchParams,
},
{
secretAccessKey: 'secretAccessKey',
accessKeyId: 'accessKeyId',
sessionToken: 'sessionToken',
},
).headers
Hope this helps ✌️
using v1.11.0 I hand the following to the
.sign()
method (partnerId and Credential modified to hide actual value):and when I call the servers get the following error:
could anyone elucidate for me what is wrong?
Appendix I
incidentally, using
node-fetch
to submit the request, like so:and yes, I've verified that the credentials are correct. the same
signedRequest
object works fine when submitted to the server via the NPMrequest
package, which I'm trying to replace withnode-fetch
as the former is deprecatedAppendix II
furthermore, if I curl with all the data displayed above, I get a success:
Appendix III
incidentally, I did find this: https://gist.github.com/i-like-robots/8913dad2204f95f0d4044b338092a584 which seems to suggest that a) the connection should implement keepAlive, and 2) there's some issue where CNAMEs need to be resolved. with reference to the latter, I've verified that the hostname being provided (agcod-v2-gamma.amazon.com) isn't a CNAME
I frankly don't know what the issue could be but if the guy who posted those gists wrote them, there must be a reason.
also incidentally, I'm trying to upgrade https://www.npmjs.com/package/agcod because Amazon doesn't offer an official NodeJs library to deal with this (sad). if anyone can recommend a better alternative I'm all ears