0

Please I'm making a POST request from my web Server(Node.js) to another web Server(Php). Can it be possible for my Node.js Server to make a preflight/OPTION request to the other PHP web server if the content-type: is application/Jason in Axios?

var axios = require('axios');
var data = {"disco_name":disco,
 "amount": 1000,
 "meter_number": 2737373,
 "MeterType": PREPAID
}
var config = {
 method: 'post',
 maxBodyLength: Infinity,
 url: 'https://datastationapi.com/api/billpayment/',
 headers: {
 'Authorization': 'Token 3cd8882f7e5e92', 
 'Content-Type': 'application/json'
 },
 data : data
};
axios(config)
.then(function (response) {
 console.log(JSON.stringify(response.data));
})
.catch(function (error) {
 console.log(error);
});
asked Aug 23, 2024 at 10:47
1
  • What problem are you trying to solve? Commented Aug 23, 2024 at 13:04

1 Answer 1

1

Preflight requests are only made by browsers, not by axios running on a server.

answered Aug 23, 2024 at 10:48
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.