Comments (13)
Not sure – not all that familiar with axios. Have you been able to do it successfully using the builtin Node.js https library as described in the README?
from aws4.
Btw, url
is not a standard property that the Node.js http module accepts. See here for accepted values:
https://nodejs.org/api/http.html#http_http_request_options_callback
from aws4.
Thanks for your very quick response. I've just tried the following and I'm getting the same error.
let request = {
host: 'xxxxxx.execute-api.eu-west-2.amazonaws.com/dev',
method: 'GET',
path: '/xxxxxx',
service: 'execute-api',
region: 'eu-west-2'
}
let signedRequest = aws4.sign(request, {
accessKeyId: rootState.auth.accessKeyId,
secretAccessKey: rootState.auth.secretAccessKey,
sessionToken: rootState.auth.sessionToken
})
console.log(signedRequest)
https.request(signedRequest, function (res) { res.pipe(process.stdout) }).end()
Console error:
"Failed to load https://xxxxxxx.execute-api.eu-west-2.amazonaws.com/dev/xxxxxx: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access. The response had HTTP status code 403. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled."
x-amzn-errortype: InvalidSignatureException
from aws4.
By the way, I'm using the following in my webpack config as you recommended elsewhere. Don't know if that has any significance here?
resolve: {
alias: {
querystring: 'querystring-browser'
}
}
from aws4.
That host doesn't look correct?
from aws4.
Also, I'm guessing you're trying to do this from the browser? Sorry, that wasn't clear in your initial issue. Try just getting it working from Node itself first – then you can tell if it's just the way you're using the browser, or something more deep seeded.
from aws4.
Yes, I'm trying from the browser. I'm building an SPA with Vue - there is no Node server.
Can you tell me what looks wrong with host? Axios doesn't require a host to be specified. Is this a requirement of aws4 or of Node.js https module?
Thanks for your help with this. I really appreciate it. I'm stuck for any alternative solution for AWS v4 signature.
from aws4.
Your host has a path in it – /dev
at the end there.
Please read up on the options here:
https://nodejs.org/api/http.html#http_http_request_options_callback
from aws4.
Success! As you suggested, fixing the host got this working with the https library. I will now try to get it working with axios and will post again here when I do.
Again, many thanks for your help.
from aws4.
No probs, glad you're getting somewhere! 👍
from aws4.
@jeremyburton Did you have any luck getting it working with Axios?
from aws4.
@alexjfno1 Yes, see this article for very useful guidance.
from aws4.
For someone who sees this, axios
also works fine with aws4
just like https
. If you see the error in the title, please double check your host
url
path
region
service
attributes in your request options.
from aws4.
Related Issues (20)
- Undefined headers throw and error
- Signature not match when try to request throught proxy url
- routines:ssl3_get_record:wrong version number
- How to Send Message to SQS using API aws4
- Rclone compatibility not working cause of header ignored HOT 2
- The request signature we calculated does not match the signature you provided HOT 1
- Amazon SP-API - Works for everything except for POST HOT 5
- Request body should allow Buffer object
- Add custom signed headers HOT 1
- Issue with latest AWS Lambda base images for NodeJS HOT 1
- AWS4 package issues with React Application
- When provided a `TE` header the request signature does not match the calculated signature.
- Extend the time of a signed url
- Headers to exclude are not excluded from the cannonicalHeaders HOT 1
- Allow `content-type` header to be disabled?
- Support SigV4a multi-region HOT 1
- Lambda@Edge signature mismatch HOT 4
- Mutating inputs can result in broken requests HOT 7
- Urgent ‼️ 🚨 Issue. HOT 9
- Account for STS no longer being a single region service HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aws4.