Reputation: 618
In my React app I sending requests to my backend node / express app using axios. In my local environment, everything works well when I call it using a function that looks like this:
await axios.post('/createproduct', createProductBody).then(res => console.log('Data send')).catch(err => console.log(err.data))
However, this after I push my code to production, this line of code returns a status code 405 (see screenshot)
Could it be because I have added the "proxy": "http://localhost:3001"
line in my package.json
file? I don't quite understand why this would work in locally
but not in prod
.
Thanks
Upvotes: 0
Views: 469
Reputation: 13245
According to the output of the below, your AWS S3 bucket is not configured to allow POST
:
axios = require('axios')
function createProductBody() {
return {}
}
async function stackOverflowQuestionNumber67929785() {
await axios.post('https://editor.blankt.io/createproduct', createProductBody()).then(res => console.log('Data send')).catch(err => console.log(err))
}
stackOverflowQuestionNumber67929785();
Prints:
response: {
status: 405,
statusText: 'Method Not Allowed',
headers: {
'content-type': 'application/xml',
'transfer-encoding': 'chunked',
connection: 'close',
allow: 'HEAD, DELETE, GET, PUT',
date: 'Fri, 11 Jun 2021 00:58:55 GMT',
server: 'AmazonS3',
'x-cache': 'Error from cloudfront',
via: '1.1 cf2a58a1ade01b9796df7d87fe311e64.cloudfront.net (CloudFront)'
}
See the allow
response header.
Upvotes: 1