Skip to content

Commit

Permalink
fix: add backend url fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
VariableVic committed May 12, 2023
1 parent c90b266 commit b6cf170
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -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=""
4 changes: 2 additions & 2 deletions lib/medusa/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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();

Expand Down

0 comments on commit b6cf170

Please sign in to comment.