Skip to content

Commit

Permalink
chore: Add hosted server url to ENV
Browse files Browse the repository at this point in the history
  • Loading branch information
builtbysuraj committed Mar 2, 2024
1 parent 9dbb42c commit 483160e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion client/src/components/form/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default function From({

// Extracting form values through 'name' property, in 'data'
const data = Object.fromEntries(formData)
const res = await axios.post(`${ENV.SERVER_URL}/${endpoint}`, data)
const res = await axios.post(`${ENV.SERVER_URL}${endpoint}`, data)
console.log(res.data)

form.reset()
Expand Down
7 changes: 4 additions & 3 deletions client/src/pages/cart/components/place-order/PlaceOrder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useAppSelector } from '@/state/store'
import { totalCartPrice } from '@/utils'
import toast from 'react-hot-toast'
import styles from './PlaceOrder.module.css'
import { ENV } from '@/conf'

declare global {
interface Window {
Expand All @@ -24,11 +25,11 @@ export default function PlaceOrder() {
const performCheckout = async () => {
const {
data: { key },
} = await axios.get('http://www.localhost:5000/api/v1/get-key')
} = await axios.get(`${ENV.SERVER_URL}/get-key`)

const {
data: { order },
} = await axios.post('http://localhost:5000/api/v1/checkout', {
} = await axios.post(`${ENV.SERVER_URL}/checkout`, {
amount,
})

Expand All @@ -40,7 +41,7 @@ export default function PlaceOrder() {
description: 'Secure payment through RazorPay',
// image: '',
order_id: order.id,
callback_url: 'http://localhost:5000/api/v1/paymentverification',
callback_url: `${ENV.SERVER_URL}/paymentverification`,
notes: {
address: 'Razorpay Corporate Office',
},
Expand Down
3 changes: 2 additions & 1 deletion client/src/pages/payment-success/PaymentSuccessPage.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ENV } from '@/conf'
import { clear } from '@/state/slices/cartSlice'
import { useAppDispatch } from '@/state/store'
import { useEffect } from 'react'
Expand All @@ -14,7 +15,7 @@ export default function PaymentSuccessPage() {
if (referenceNum) {
console.log(referenceNum)
const response = await fetch(
`http://localhost:5000/api/v1/verify-payment?paymentId=${referenceNum}`
`${ENV.SERVER_URL}/verify-payment?paymentId=${referenceNum}`
)
const data = await response.json()
if (data.success) {
Expand Down

0 comments on commit 483160e

Please sign in to comment.