Region id is now a environment variable

fix hardcoding of localhost in cart
This commit is contained in:
Amritanshu Agrawal 2024-10-17 08:15:46 +05:30
parent 9c93849c8b
commit 8589d0f784
3 changed files with 4 additions and 10 deletions

View File

@ -17,8 +17,9 @@ export default function ProductsPage() {
const params = new URLSearchParams({
// fields: `*variants.calculated_price`,
fields: `*variants.prices.*`,
region_id: 'reg_01J988N552JQQZAJ7QJ3Y873QD',
region_id: process.env.NEXT_PUBLIC_DEFAULT_REGION_ID as string,
});
console.log('url: ', `${process.env.NEXT_PUBLIC_BASE_URL}/store/products?${params}`);
fetch(`${process.env.NEXT_PUBLIC_BASE_URL}/store/products?${params}`, {
credentials: 'include',
headers: {

View File

@ -1,14 +1,7 @@
import Medusa from '@medusajs/js-sdk';
// Defaults to standard port for Medusa server
let MEDUSA_BACKEND_URL = 'http://localhost:9000';
if (process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL) {
MEDUSA_BACKEND_URL = process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL;
}
export const sdk = new Medusa({
baseUrl: MEDUSA_BACKEND_URL,
baseUrl: process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL as string,
debug: process.env.NODE_ENV === 'development',
publishableKey: process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY,
});

View File

@ -73,7 +73,7 @@ export const CartProvider = ({ children }: CartProviderProps) => {
return;
}
fetch(`http://localhost:9000/store/carts/${cart.id}/line-items`, {
fetch(`${process.env.NEXT_PUBLIC_BASE_URL}/store/carts/${cart.id}/line-items`, {
credentials: 'include',
method: 'POST',
headers: {