Skip to content

Commit ce48f3d

Browse files
Fix: Update CSP for external services
The Content Security Policy (CSP) was updated to include necessary domains for external services like `exchangerate-api.com` and `tawk.to`. This resolves "Refused to connect" errors related to these services and ensures they function correctly.
1 parent 5677a65 commit ce48f3d

3 files changed

Lines changed: 14 additions & 3 deletions

File tree

api/stripe-payment-methods.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,18 @@ export default async function handler(req, res) {
2828
type: 'card'
2929
});
3030

31-
res.status(200).json({ paymentMethods: paymentMethods.data });
31+
// Format the payment methods to match the expected structure
32+
const formattedMethods = paymentMethods.data.map(pm => ({
33+
id: pm.id,
34+
type: pm.type,
35+
last4: pm.card?.last4 || '',
36+
brand: pm.card?.brand || '',
37+
exp_month: pm.card?.exp_month || 0,
38+
exp_year: pm.card?.exp_year || 0,
39+
isDefault: customer.invoice_settings?.default_payment_method === pm.id
40+
}));
41+
42+
res.status(200).json({ paymentMethods: formattedMethods });
3243
} catch (error) {
3344
console.error('Error fetching payment methods:', error);
3445
res.status(500).json({ error: error.message });

src/components/PaymentMethodSelector.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export const PaymentMethodSelector = ({
7878
)}
7979
</div>
8080
<p className="text-sm text-slate-600">
81-
Expire {card.exp_month.toString().padStart(2, '0')}/{card.exp_year}
81+
Expire {card.exp_month?.toString().padStart(2, '0') || '00'}/{card.exp_year || '0000'}
8282
</p>
8383
</div>
8484
</div>

vercel.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
},
3333
{
3434
"key": "Content-Security-Policy",
35-
"value": "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://cdn.gpteng.co https://embed.tawk.to https://va.tawk.to; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com; img-src 'self' data: https:; connect-src 'self' https://api.stripe.com https://refspring-default-rtdb.europe-west1.firebasedatabase.app https://identitytoolkit.googleapis.com https://securetoken.googleapis.com https://firestore.googleapis.com https://us-central1-refspring-8c3ac.cloudfunctions.net wss://embed.tawk.to; frame-src https://js.stripe.com https://embed.tawk.to; object-src 'none'; base-uri 'self'; upgrade-insecure-requests"
35+
"value": "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://cdn.gpteng.co https://embed.tawk.to https://va.tawk.to; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com; img-src 'self' data: https:; connect-src 'self' https://api.stripe.com https://refspring-default-rtdb.europe-west1.firebasedatabase.app https://identitytoolkit.googleapis.com https://securetoken.googleapis.com https://firestore.googleapis.com https://us-central1-refspring-8c3ac.cloudfunctions.net https://api.exchangerate-api.com https://va.tawk.to https://embed.tawk.to wss://embed.tawk.to; frame-src https://js.stripe.com https://embed.tawk.to; object-src 'none'; base-uri 'self'; upgrade-insecure-requests"
3636
}
3737
]
3838
}

0 commit comments

Comments
 (0)