When I do a test call ti my website, got an 504 error in https://console.cron-job.org, why?
I even did set up CORS to avaind any issues.
Seems that the endpoint is triggered, but then why not response is seen by https://console.cron-job.org?
import { NextApiRequest, NextApiResponse } from 'next'
import { prepareAndSendInvoices } from 'services/sendInvoices'
import { sendWelcomeMessages } from 'services/sendWelcomeMessages'
import { sendMessageToWaitingList } from 'services/sendMessageToWaitingList'
import { connectToDatabase } from 'lib/connectToDatabase'
import { Db } from 'mongodb'
export default async function handler(
req: NextApiRequest,
res: NextApiResponse
) {
const { mongoClient } = await connectToDatabase()
const db: Db = mongoClient.db('tikex')
await db.collection('logs').insertOne({
api: 'processPaymentTasks',
createdAt: new Date(),
severity: 'log',
})
await prepareAndSendInvoices({ db })
await db.collection('logs').insertOne({
api: 'processPaymentTasks > sendWelcomeMessages',
createdAt: new Date(),
severity: 'log',
})
await sendWelcomeMessages({ db })
await db.collection('logs').insertOne({
api: 'processPaymentTasks > sendMessageToWaitingList',
createdAt: new Date(),
severity: 'log',
})
await sendMessageToWaitingList({ db })
return res.status(200).end()
}
//-