feat(MED-131): conditional env

This commit is contained in:
2025-08-04 18:31:17 +03:00
parent bd78b28f3c
commit 47675252ed
2 changed files with 10 additions and 16 deletions

View File

@@ -8,10 +8,7 @@ import { StoreCartLineItem, StoreProductVariant } from '@medusajs/types';
import { MontonioOrderHandlerService } from '@/packages/billing/montonio/src';
import { requireUserInServerComponent } from '../server/require-user-in-server-component';
const medusaBackendPublicUrl = process.env.MEDUSA_BACKEND_PUBLIC_URL!;
const siteUrl = process.env.NEXT_PUBLIC_SITE_URL!;
const env = z
const env = () => z
.object({
medusaBackendPublicUrl: z
.string({
@@ -25,8 +22,8 @@ const env = z
.min(1),
})
.parse({
medusaBackendPublicUrl,
siteUrl,
medusaBackendPublicUrl: process.env.MEDUSA_BACKEND_PUBLIC_URL!,
siteUrl: process.env.NEXT_PUBLIC_SITE_URL!,
});
export async function handleAddToCart({
@@ -81,8 +78,8 @@ export async function handleNavigateToPayment({ language, paymentSessionId }: {
}
const paymentLink = await new MontonioOrderHandlerService().getMontonioPaymentLink({
notificationUrl: `${env.medusaBackendPublicUrl}/hooks/payment/montonio_montonio`,
returnUrl: `${env.siteUrl}/home/cart/montonio-callback`,
notificationUrl: `${env().medusaBackendPublicUrl}/hooks/payment/montonio_montonio`,
returnUrl: `${env().siteUrl}/home/cart/montonio-callback`,
amount: cart.total,
currency: cart.currency_code.toUpperCase(),
description: `Order from Medreport`,