Skip to content

Commit b83fb1c

Browse files
committed
fix: use relative API URL with Vercel proxy to fix UPI/card payment 405 error
1 parent 40268a0 commit b83fb1c

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

frontend/src/components/Checkout.jsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,11 @@ const Checkout = ({ cartItems, onClose, onOrderPlaced }) => {
3636
const loaded = await loadRazorpayScript();
3737
if (!loaded) { alert('Razorpay failed to load. Check your internet.'); return; }
3838

39+
// Use relative URL so it works on any deployment (Vercel proxy handles it)
40+
const apiBase = import.meta.env.VITE_API_URL || '';
41+
3942
try {
40-
const res = await fetch(`${import.meta.env.VITE_API_URL}/api/payment/create-order`, {
43+
const res = await fetch(`${apiBase}/api/payment/create-order`, {
4144
method: 'POST',
4245
headers: { 'Content-Type': 'application/json' },
4346
body: JSON.stringify({ amount: totalAmount }),
@@ -60,7 +63,7 @@ const Checkout = ({ cartItems, onClose, onOrderPlaced }) => {
6063
description: 'Shoe Purchase',
6164
order_id: data.orderId,
6265
handler: async (response) => {
63-
const verifyRes = await fetch(`${import.meta.env.VITE_API_URL}/api/payment/verify`, {
66+
const verifyRes = await fetch(`${apiBase}/api/payment/verify`, {
6467
method: 'POST',
6568
headers: { 'Content-Type': 'application/json' },
6669
body: JSON.stringify(response),

frontend/vercel.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
{ "source": "/preview", "destination": "/", "permanent": true }
44
],
55
"rewrites": [
6+
{ "source": "/api/:path*", "destination": "https://zappify-dz5a.vercel.app/api/:path*" },
67
{ "source": "/(.*)", "destination": "/index.html" }
78
]
89
}

0 commit comments

Comments
 (0)