Region id is now a environment variable
fix hardcoding of localhost in cart
This commit is contained in:
@ -17,8 +17,9 @@ export default function ProductsPage() {
|
|||||||
const params = new URLSearchParams({
|
const params = new URLSearchParams({
|
||||||
// fields: `*variants.calculated_price`,
|
// fields: `*variants.calculated_price`,
|
||||||
fields: `*variants.prices.*`,
|
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}`, {
|
fetch(`${process.env.NEXT_PUBLIC_BASE_URL}/store/products?${params}`, {
|
||||||
credentials: 'include',
|
credentials: 'include',
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
@ -1,14 +1,7 @@
|
|||||||
import Medusa from '@medusajs/js-sdk';
|
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({
|
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',
|
debug: process.env.NODE_ENV === 'development',
|
||||||
publishableKey: process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY,
|
publishableKey: process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY,
|
||||||
});
|
});
|
||||||
|
|||||||
@ -73,7 +73,7 @@ export const CartProvider = ({ children }: CartProviderProps) => {
|
|||||||
return;
|
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',
|
credentials: 'include',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
Reference in New Issue
Block a user