diff --git a/apps/portal/src/components/pages/SupportPage.js b/apps/portal/src/components/pages/SupportPage.js index 4f5f956ae7..40c62e8e69 100644 --- a/apps/portal/src/components/pages/SupportPage.js +++ b/apps/portal/src/components/pages/SupportPage.js @@ -15,7 +15,7 @@ const SupportPage = () => { const siteUrl = window.location.origin; const currentUrl = siteUrl + window.location.pathname; const successUrl = `${currentUrl}#/portal/support/success`; - const cancelUrl = `${currentUrl}#/portal/support/error`; + const cancelUrl = currentUrl; const api = setupGhostApi({siteUrl}); try { diff --git a/apps/portal/src/utils/api.js b/apps/portal/src/utils/api.js index 43ca60b3d0..5ff3752be0 100644 --- a/apps/portal/src/utils/api.js +++ b/apps/portal/src/utils/api.js @@ -424,14 +424,14 @@ function setupGhostApi({siteUrl = window.location.origin, apiUrl, apiKey}) { body: JSON.stringify(body) }); - if (!response.ok) { - const errorData = await response.json(); - const errorMessage = errorData?.errors?.[0]?.message || 'There was an error processing your payment. Please try again.'; + const responseJson = await response.json(); + if (!response.ok) { + const errorMessage = responseJson?.errors?.[0]?.message || 'There was an error processing your payment. Please try again.'; throw new Error(errorMessage); } - return response.json(); + return responseJson; }, async editBilling({successUrl, cancelUrl, subscriptionId} = {}) {