mirror of
https://gitlab.com/davidels1986/ore-cart-checkout.git
synced 2026-10-30 02:59:13 +00:00
Switched webhook fetch to no-cors mode
Updated src/lib/webhookService.ts to send webhook requests in no-cors mode with text/plain content, logging opaque success and avoiding response handling. X-Lovable-Edit-ID: edt-bf640d1d-1036-4e97-818c-2ecab3f5380c
This commit is contained in:
commit
44a6d5efa1
1 changed files with 6 additions and 11 deletions
|
|
@ -112,21 +112,16 @@ export async function sendQuoteWebhook(
|
|||
try {
|
||||
const response = await fetch(WEBHOOK_URL, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
mode: 'no-cors',
|
||||
headers: { 'Content-Type': 'text/plain' },
|
||||
body: JSON.stringify(payload),
|
||||
signal: controller.signal,
|
||||
});
|
||||
|
||||
const responseBody = await response.text();
|
||||
console.log('📥 Webhook response status:', response.status);
|
||||
console.log('📥 Webhook response body:', responseBody);
|
||||
|
||||
if (!response.ok) {
|
||||
return {
|
||||
success: false,
|
||||
error: `Webhook returned status ${response.status}. Please try again.`,
|
||||
};
|
||||
}
|
||||
// In no-cors mode, response is opaque (status 0, no body readable).
|
||||
// If fetch didn't throw, the request was sent successfully.
|
||||
console.log('📥 Webhook response type:', response.type);
|
||||
console.log('📥 Webhook sent successfully (no-cors mode)');
|
||||
|
||||
return { success: true };
|
||||
} catch (err: unknown) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue