fix: add backend url fallback

This commit is contained in:
Victor Gerbrands 2023-05-12 15:10:28 +02:00
parent c90b2664b7
commit b6cf1704ae
2 changed files with 3 additions and 3 deletions

View File

@ -1,6 +1,6 @@
TWITTER_CREATOR="@medusajs"
TWITTER_SITE="https://medusajs.com/"
SITE_NAME="Next.js Commerce by Medusa"
NEXT_PUBLIC_MEDUSA_BACKEND_API="http://localhost:9000/store"
NEXT_PUBLIC_MEDUSA_BACKEND_API="http://localhost:9000"
NEXT_PUBLIC_VERCEL_URL="http://localhost:3000"
MEDUSA_API_KEY=""

View File

@ -19,7 +19,7 @@ import {
SelectedOption
} from './types';
const ENDPOINT = process.env.NEXT_PUBLIC_MEDUSA_BACKEND_API;
const ENDPOINT = process.env.NEXT_PUBLIC_MEDUSA_BACKEND_API ?? 'http://localhost:9000';
const MEDUSA_API_KEY = process.env.MEDUSA_API_KEY ?? '';
const REVALIDATE_WINDOW = parseInt(process.env.REVALIDATE_WINDOW ?? `${60 * 15}`); // 15 minutes
@ -45,7 +45,7 @@ export default async function medusaRequest(
}
try {
const result = await fetch(`${ENDPOINT}${path}`, options);
const result = await fetch(`${ENDPOINT}/store${path}`, options);
const body = await result.json();