Fix:
- Merubah kode dan menambah enCode untuk dikirim ke Whatsapp - src/app/api/auth/login/route.ts & src/app/api/auth/resend/route.ts ### No Issue
This commit is contained in:
30
sendWhatsapp.js
Normal file
30
sendWhatsapp.js
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
// sendWhatsapp.js
|
||||||
|
|
||||||
|
// --- INPUT MANUAL ---
|
||||||
|
let phoneNumber = "6282340374412";
|
||||||
|
const codeOtp = "3546";
|
||||||
|
// ---------------------
|
||||||
|
|
||||||
|
phoneNumber = phoneNumber.replace(/\D/g, "");
|
||||||
|
|
||||||
|
// Format pesan
|
||||||
|
const message =
|
||||||
|
`HIPMI - Kode ini bersifat RAHASIA dan JANGAN DI BAGIKAN KEPADA SIAPAPUN, termasuk anggota ataupun pengurus HIPMI lainnya.\n\n` +
|
||||||
|
`>> Kode OTP anda: ${codeOtp}.`;
|
||||||
|
|
||||||
|
const encodedMessage = encodeURIComponent(message);
|
||||||
|
|
||||||
|
const waLink = `https://wa.wibudev.com/code?nom=${phoneNumber}&text=${encodedMessage}`;
|
||||||
|
|
||||||
|
console.log("Mengirim request ke server...\n");
|
||||||
|
|
||||||
|
// Jalankan HTTP GET
|
||||||
|
fetch(waLink)
|
||||||
|
.then(res => res.text())
|
||||||
|
.then(data => {
|
||||||
|
console.log("Response dari server:");
|
||||||
|
console.log(data);
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
console.error("Terjadi error:", err);
|
||||||
|
});
|
||||||
@@ -29,11 +29,12 @@ export async function POST(req: Request) {
|
|||||||
{ status: 400 }
|
{ status: 400 }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const msg = `HIPMI - Kode ini bersifat RAHASIA dan JANGAN DI BAGIKAN KEPADA SIAPAPUN, termasuk anggota ataupun pengurus HIPMI lainnya.\n\n>> Kode OTP anda: ${codeOtp}.`;
|
||||||
|
const encodedMsg = encodeURIComponent(msg);
|
||||||
|
|
||||||
const res = await fetch(
|
const res = await fetch(
|
||||||
`https://wa.wibudev.com/code?nom=${nomor}&text=HIPMI - Kode ini bersifat RAHASIA dan JANGAN DI BAGIKAN KEPADA SIAPAPUN, termasuk anggota ataupun pengurus HIPMI lainnya.
|
`https://wa.wibudev.com/code?nom=${nomor}&text=${encodedMsg}`,
|
||||||
\n
|
{ cache: "no-cache" }
|
||||||
>> Kode OTP anda: ${codeOtp}.
|
|
||||||
`
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const sendWa = await res.json();
|
const sendWa = await res.json();
|
||||||
@@ -62,7 +63,5 @@ export async function POST(req: Request) {
|
|||||||
},
|
},
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
);
|
);
|
||||||
} finally {
|
|
||||||
await prisma.$disconnect();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,14 +16,16 @@ export async function POST(req: Request) {
|
|||||||
const body = await req.json();
|
const body = await req.json();
|
||||||
const { nomor } = body;
|
const { nomor } = body;
|
||||||
|
|
||||||
|
const msg = `HIPMI - Kode ini bersifat RAHASIA dan JANGAN DI BAGIKAN KEPADA SIAPAPUN, termasuk anggota ataupun pengurus HIPMI lainnya.\n\n>> Kode OTP anda: ${codeOtp}.`;
|
||||||
|
const encodedMsg = encodeURIComponent(msg);
|
||||||
|
|
||||||
const res = await fetch(
|
const res = await fetch(
|
||||||
`https://wa.wibudev.com/code?nom=${nomor}&text=HIPMI - Kode ini bersifat RAHASIA dan JANGAN DI BAGIKAN KEPADA SIAPAPUN, termasuk anggota ataupun pengurus HIPMI lainnya.
|
`https://wa.wibudev.com/code?nom=${nomor}&text=${encodedMsg}`,
|
||||||
\n
|
{ cache: "no-cache" }
|
||||||
>> Kode OTP anda: ${codeOtp}.
|
|
||||||
`
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const sendWa = await res.json();
|
const sendWa = await res.json();
|
||||||
|
|
||||||
if (sendWa.status !== "success")
|
if (sendWa.status !== "success")
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user