Separate client and server urls.
This commit is contained in:
parent
d4373138fa
commit
0c523359eb
@ -39,7 +39,7 @@ const ProductDetails: FC<ProductDetailsProps> = ({ handle }) => {
|
||||
region_id: region?.id as string,
|
||||
});
|
||||
const products: HttpTypes.StoreProduct[] = await fetch(
|
||||
`${process.env.NEXT_PUBLIC_BASE_URL}/store/products?${params}`,
|
||||
`${process.env.NEXT_PUBLIC_STORE_URL}/store/products?${params}`,
|
||||
{
|
||||
credentials: 'include',
|
||||
headers: {
|
||||
|
@ -10,7 +10,7 @@ interface ProductPageProps {
|
||||
}
|
||||
// export async function generateStaticParams() {
|
||||
// // Fetch the list of products
|
||||
// const products: HttpTypes.StoreProduct[] = await fetch(`${process.env.NEXT_PUBLIC_BASE_URL}/store/products`, {
|
||||
// const products: HttpTypes.StoreProduct[] = await fetch(`${process.env.NEXT_PUBLIC_STORE_URL}/store/products`, {
|
||||
// credentials: 'include',
|
||||
// headers: {
|
||||
// 'Content-Type': 'application/json',
|
||||
|
@ -9,7 +9,7 @@ async function fetchProducts() {
|
||||
region_id: process.env.NEXT_PUBLIC_DEFAULT_REGION_ID as string,
|
||||
});
|
||||
|
||||
const response = await fetch(`${process.env.NEXT_PUBLIC_BASE_URL}/store/products?${params}`, {
|
||||
const response = await fetch(`${process.env.NEXT_PRIVATE_BASE_URL}/store/products?${params}`, {
|
||||
credentials: 'include',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
|
@ -32,7 +32,7 @@ export const CartProvider = ({ children }: CartProviderProps) => {
|
||||
const cartId = localStorage.getItem('cart_id');
|
||||
if (!cartId) {
|
||||
// create a cart
|
||||
fetch(`${process.env.NEXT_PUBLIC_BASE_URL}/store/carts`, {
|
||||
fetch(`${process.env.NEXT_PUBLIC_STORE_URL}/store/carts`, {
|
||||
method: 'POST',
|
||||
credentials: 'include',
|
||||
headers: {
|
||||
@ -50,7 +50,7 @@ export const CartProvider = ({ children }: CartProviderProps) => {
|
||||
});
|
||||
} else {
|
||||
// retrieve cart
|
||||
fetch(`${process.env.NEXT_PUBLIC_BASE_URL}/store/carts/${cartId}`, {
|
||||
fetch(`${process.env.NEXT_PUBLIC_STORE_URL}/store/carts/${cartId}`, {
|
||||
credentials: 'include',
|
||||
headers: {
|
||||
'x-publishable-api-key': process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY as string,
|
||||
@ -73,7 +73,7 @@ export const CartProvider = ({ children }: CartProviderProps) => {
|
||||
return;
|
||||
}
|
||||
|
||||
fetch(`${process.env.NEXT_PUBLIC_BASE_URL}/store/carts/${cart.id}/line-items`, {
|
||||
fetch(`${process.env.NEXT_PUBLIC_STORE_URL}/store/carts/${cart.id}/line-items`, {
|
||||
credentials: 'include',
|
||||
method: 'POST',
|
||||
headers: {
|
||||
@ -98,7 +98,7 @@ export const CartProvider = ({ children }: CartProviderProps) => {
|
||||
return;
|
||||
}
|
||||
|
||||
fetch(`${process.env.NEXT_PUBLIC_BASE_URL}/store/carts/${cart.id}/line-items/${item_id}`, {
|
||||
fetch(`${process.env.NEXT_PUBLIC_STORE_URL}/store/carts/${cart.id}/line-items/${item_id}`, {
|
||||
credentials: 'include',
|
||||
method: 'POST',
|
||||
headers: {
|
||||
@ -122,7 +122,7 @@ export const CartProvider = ({ children }: CartProviderProps) => {
|
||||
return;
|
||||
}
|
||||
|
||||
fetch(`${process.env.NEXT_PUBLIC_BASE_URL}/store/carts/${cart.id}/line-items/${item_id}`, {
|
||||
fetch(`${process.env.NEXT_PUBLIC_STORE_URL}/store/carts/${cart.id}/line-items/${item_id}`, {
|
||||
credentials: 'include',
|
||||
headers: {
|
||||
'x-publishable-api-key': process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY as string,
|
||||
|
@ -122,7 +122,7 @@ export const CustomerProvider = ({ children }: CustomerProviderProps) => {
|
||||
};
|
||||
const getJwt = async (email: string, password: string) => {
|
||||
try {
|
||||
const { token } = await fetch(`${process.env.NEXT_PUBLIC_BASE_URL}/auth/customer/emailpass`, {
|
||||
const { token } = await fetch(`${process.env.NEXT_PUBLIC_STORE_URL}/auth/customer/emailpass`, {
|
||||
credentials: 'include',
|
||||
method: 'POST',
|
||||
headers: {
|
||||
@ -147,7 +147,7 @@ export const CustomerProvider = ({ children }: CustomerProviderProps) => {
|
||||
};
|
||||
const registerEmail = async (email: string, password: string) => {
|
||||
try {
|
||||
const { token } = await fetch(`${process.env.NEXT_PUBLIC_BASE_URL}/auth/customer/emailpass/register`, {
|
||||
const { token } = await fetch(`${process.env.NEXT_PUBLIC_STORE_URL}/auth/customer/emailpass/register`, {
|
||||
credentials: 'include',
|
||||
method: 'POST',
|
||||
headers: {
|
||||
@ -176,7 +176,7 @@ export const CustomerProvider = ({ children }: CustomerProviderProps) => {
|
||||
return;
|
||||
}
|
||||
// get customer
|
||||
const response = await fetch(`${process.env.NEXT_PUBLIC_BASE_URL}/store/customers/me`, {
|
||||
const response = await fetch(`${process.env.NEXT_PUBLIC_STORE_URL}/store/customers/me`, {
|
||||
credentials: 'include',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
@ -198,7 +198,7 @@ export const CustomerProvider = ({ children }: CustomerProviderProps) => {
|
||||
return;
|
||||
}
|
||||
// create customer
|
||||
const response = await fetch(`${process.env.NEXT_PUBLIC_BASE_URL}/store/customers`, {
|
||||
const response = await fetch(`${process.env.NEXT_PUBLIC_STORE_URL}/store/customers`, {
|
||||
credentials: 'include',
|
||||
method: 'POST',
|
||||
headers: {
|
||||
|
@ -28,7 +28,7 @@ export const RegionProvider = ({ children }: RegionProviderProps) => {
|
||||
const regionId = localStorage.getItem('region_id');
|
||||
if (!regionId) {
|
||||
// retrieve regions and select the first one
|
||||
fetch(`${process.env.NEXT_PUBLIC_BASE_URL}/store/regions`, {
|
||||
fetch(`${process.env.NEXT_PUBLIC_STORE_URL}/store/regions`, {
|
||||
credentials: 'include',
|
||||
headers: {
|
||||
'x-publishable-api-key': process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY as string,
|
||||
@ -40,7 +40,7 @@ export const RegionProvider = ({ children }: RegionProviderProps) => {
|
||||
});
|
||||
} else {
|
||||
// retrieve selected region
|
||||
fetch(`${process.env.NEXT_PUBLIC_BASE_URL}/store/regions/${regionId}`, {
|
||||
fetch(`${process.env.NEXT_PUBLIC_STORE_URL}/store/regions/${regionId}`, {
|
||||
credentials: 'include',
|
||||
headers: {
|
||||
'x-publishable-api-key': process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY as string,
|
||||
|
Loading…
Reference in New Issue
Block a user