Sounds like you're missing something on the API Gateway side of things.
You'll need two API Methods for the CORS: OPTIONS and POST.
For OPTIONS, you'll want to make sure that the Method Response section contains the following headers:
Next, you'll want to configure the Integration Response section for the OPTIONS method, to include the values
For POST, you'll want to make sure that the Method Response section contains the following headers:
Next, you'll want to configure the Integration Response section for the POST method, to include the values:
With that in place, you should be able to call API gateway using Axios by doing the following:
import axios from "axios"; (async () => { const result = await axios.post("https://3xqqgy12ga.execute-api.us-east-1.amazonaws.com/Test/testwithcorsenabled", null, { headers: { "Content-Type": "application/json" } }); console.log(result); })().catch(e => { });
Notice that 'Content-Type' was one of the allowed headers in the OPTIONS Integration Response section.
On success, the browser dev tools should show an OPTIONS request being fired and then a POST right after:
My approach would be to spin up a test API Gateway, decide what headers you'll need back and incrementally add / test them using Axios for the POST.
Hopefully this helps a little bit ^^
Really thanks for spending your time to help me. Its now work :)
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Sounds like you're missing something on the API Gateway side of things.
You'll need two API Methods for the CORS: OPTIONS and POST.
Options Method
For OPTIONS, you'll want to make sure that the Method Response section contains the following headers:
Next, you'll want to configure the Integration Response section for the OPTIONS method, to include the values
Post Method
For POST, you'll want to make sure that the Method Response section contains the following headers:
Next, you'll want to configure the Integration Response section for the POST method, to include the values:
With that in place, you should be able to call API gateway using Axios by doing the following:
Notice that 'Content-Type' was one of the allowed headers in the OPTIONS Integration Response section.
On success, the browser dev tools should show an OPTIONS request being fired and then a POST right after:
My approach would be to spin up a test API Gateway, decide what headers you'll need back and incrementally add / test them using Axios for the POST.
Hopefully this helps a little bit ^^
Really thanks for spending your time to help me. Its now work :)