I have a simple NextJS app running in Vercel. I cloned the NextJS template given by Vercel and added just one file called jira.js
I am just trying to post random data to external API when this jira is hit.
Jira.js is the following
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
import axios from 'axios'
import https from 'https'
export default (req, res) => {
const headers = {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*'
}
axios.post('https://webhook.site/6db7a14b-48d7-4037-a482-86885526aa40', {
Name: 'Fred',
Age: '23'
}, {
headers: headers,
withCredentials: true
}
).then(function(res) {
console.log({res: res})
}).catch(function(e) {
console.log({"failed": e})
})
res.json({ status: 'ok' })
}
When I try it locallly (localhost:3000/api/jira), the data is getting posted to the Webhook site, but when I deploy it to vercel(random-domain.com/api/jira) then there is no posting of data in webhook site, but I get Status: ok messsage in the browser.
I am pretty new to this? Can somoene guide me with what I am missing?