Hello there !
So I’m building a function that I must send a “POST” request with some data in the body. It work all great in local but when I go on live no matter what I do the event.httpMethod
is “GET”
.
here is my .toml
[build]
functions = "functions"
[[redirects]]
from= "/api/*"
to= "/.netlify/functions/:splat"
status= 200
[[headers]]
for = "/*"
[headers.values]
Access-Control-Allow-Origin = "*"
and this is my test function
exports.handler = async function(event, context) {
if (event.httpMethod !== "POST") {
// To enable CORS
console.log("preflight");
return {
statusCode: 200,
body: "This was not a POST request!"
};
}
console.log("hello");
// console.log(event);
console.log(event.headers["client-ip"]);
console.log(event.body);
return {
statusCode: 200,
body: JSON.stringify({ message: "hello there" })
};
};
Hope someone can help.