aws-amplify / aws-amplify/amplify-hosting
First time using Amplify and facing issues with axios post requests
- Dominant language
- Dockerfile
- Stars
- 481
- Forks
- 123
- PR merge metrics
- No merged PRs in 30d
Description
I have a ReactJS frontend and using Axios to send requests to my nodeJS backend, which is running in Fargate. The frontend build runs on localhost, connecting to the backend within ECS. I can also send post requests to the backend from Postman with no issues. NodeJS has cors setup.
After I build the Amplify image the login page loads, but I'm getting a 405 method is not allowed.
After some research, I found some examples where the preflighted request was failing. I've added headers to my Axios post request, which still works locally, but still fails when using Amplify.
The Axios post:
`const login = async (userData) => {
console.log('service :', loginurl)
const head = {
headers: { 'content-type': 'application/x-www-form-urlencoded' }
}
const response = await axios.post(
loginurl,
userData,
{ headers: head })
((more to to check response.data and return back - didn't add in copy/paste here)
}`
The response header (Chrome console):
allow: HEAD, DELETE, GET, PUT
x-cache: Error from cloudfront
Not sure where I go from here, any help would be appreciated.
Contributor guide
Research direction
The issue names only the Axios login call and Chrome response headers; start by comparing the deployed browser request with the working Postman request and checking the preflight response. Confirm whether the 405 is returned by the hosted frontend or CloudFront path or by the Fargate Node.js backend, then capture the deployment and request configuration needed to reproduce the failure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, javascript, node.js, react
- Domain
- api, backend, cloud, frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100