diff --git a/actions/auth-actions.ts b/actions/auth-actions.ts index b824b2d..3cbfc27 100644 --- a/actions/auth-actions.ts +++ b/actions/auth-actions.ts @@ -132,15 +132,16 @@ export async function signup(_actionState: ActionState, formData: FormData) { export const sendOtp = async (phoneNumber: string, code: string) => { // Implement sending OTP code via SMS console.log("Send OTP server fn", phoneNumber, code); - const respose = await fetch("https://smsapi.sarlink.link/send", { + const respose = await fetch(`${process.env.SMS_API_BASE_URL}/api/sms`, { method: "POST", headers: { "Content-Type": "application/json", + Authorization: `Bearer ${process.env.SMS_API_KEY}`, }, body: JSON.stringify({ - api_key: process.env.SMS_API_KEY, + check_delivery: false, number: phoneNumber, - text: `Your OTP code is ${code}`, + message: `Your OTP code is ${code}`, }), }); const data = await respose.json(); diff --git a/actions/user-actions.ts b/actions/user-actions.ts index 5097c58..bb91bd4 100644 --- a/actions/user-actions.ts +++ b/actions/user-actions.ts @@ -80,15 +80,16 @@ export const SendUserRejectionDetailSMS = async ({ details: string; phoneNumber: string; }) => { - const respose = await fetch("https://smsapi.sarlink.link/send", { + const respose = await fetch(`${process.env.SMS_API_BASE_URL}/api/sms`, { method: "POST", headers: { "Content-Type": "application/json", + Authorization: `Bearer ${process.env.SMS_API_KEY}`, }, body: JSON.stringify({ - api_key: process.env.SMS_API_KEY, + check_delivery: false, number: phoneNumber, - text: details, + message: details, }), }); const data = await respose.json(); diff --git a/app/api/check-devices/route.ts b/app/api/check-devices/route.ts index 8fab37d..ea2bba4 100644 --- a/app/api/check-devices/route.ts +++ b/app/api/check-devices/route.ts @@ -128,15 +128,16 @@ async function sendNotifySms( phoneNumber: string, deviceName?: string, ) { - const respose = await fetch("https://smsapi.sarlink.link/send", { + const respose = await fetch(`${process.env.SMS_API_BASE_URL}/api/sms`, { method: "POST", headers: { "Content-Type": "application/json", + Authorization: `Bearer ${process.env.SMS_API_KEY}`, }, body: JSON.stringify({ - api_key: process.env.SMS_API_KEY, + check_delivery: false, number: phoneNumber, - text: `REMINDER! Your device [${deviceName}] will expire on ${new Date(expireDate)}.`, + message: `REMINDER! Your device [${deviceName}] will expire on ${new Date(expireDate)}.`, }), }); const data = await respose.json();