mirror of
https://github.com/i701/sarlink-portal.git
synced 2025-06-29 13:43:58 +00:00
Refactor SMS notification handling to use environment variables
- Updated SMS API calls in auth-actions.ts, user-actions.ts, and check-devices/route.ts to utilize environment variables for the base URL and API key. - Changed request body parameters from 'text' to 'message' and added 'check_delivery' to improve SMS delivery tracking. These changes enhance security and maintainability by centralizing configuration settings.
This commit is contained in:
@ -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();
|
||||
|
Reference in New Issue
Block a user