Separate client and server urls.

This commit is contained in:
2024-10-17 09:35:02 +05:30
parent d4373138fa
commit 0c523359eb
6 changed files with 14 additions and 14 deletions

View File

@ -39,7 +39,7 @@ const ProductDetails: FC<ProductDetailsProps> = ({ handle }) => {
region_id: region?.id as string, region_id: region?.id as string,
}); });
const products: HttpTypes.StoreProduct[] = await fetch( 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', credentials: 'include',
headers: { headers: {

View File

@ -10,7 +10,7 @@ interface ProductPageProps {
} }
// export async function generateStaticParams() { // export async function generateStaticParams() {
// // Fetch the list of products // // 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', // credentials: 'include',
// headers: { // headers: {
// 'Content-Type': 'application/json', // 'Content-Type': 'application/json',

View File

@ -9,7 +9,7 @@ async function fetchProducts() {
region_id: process.env.NEXT_PUBLIC_DEFAULT_REGION_ID as string, 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', credentials: 'include',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',

View File

@ -32,7 +32,7 @@ export const CartProvider = ({ children }: CartProviderProps) => {
const cartId = localStorage.getItem('cart_id'); const cartId = localStorage.getItem('cart_id');
if (!cartId) { if (!cartId) {
// create a cart // create a cart
fetch(`${process.env.NEXT_PUBLIC_BASE_URL}/store/carts`, { fetch(`${process.env.NEXT_PUBLIC_STORE_URL}/store/carts`, {
method: 'POST', method: 'POST',
credentials: 'include', credentials: 'include',
headers: { headers: {
@ -50,7 +50,7 @@ export const CartProvider = ({ children }: CartProviderProps) => {
}); });
} else { } else {
// retrieve cart // retrieve cart
fetch(`${process.env.NEXT_PUBLIC_BASE_URL}/store/carts/${cartId}`, { fetch(`${process.env.NEXT_PUBLIC_STORE_URL}/store/carts/${cartId}`, {
credentials: 'include', credentials: 'include',
headers: { headers: {
'x-publishable-api-key': process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY as string, 'x-publishable-api-key': process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY as string,
@ -73,7 +73,7 @@ export const CartProvider = ({ children }: CartProviderProps) => {
return; 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', credentials: 'include',
method: 'POST', method: 'POST',
headers: { headers: {
@ -98,7 +98,7 @@ export const CartProvider = ({ children }: CartProviderProps) => {
return; 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', credentials: 'include',
method: 'POST', method: 'POST',
headers: { headers: {
@ -122,7 +122,7 @@ export const CartProvider = ({ children }: CartProviderProps) => {
return; 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', credentials: 'include',
headers: { headers: {
'x-publishable-api-key': process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY as string, 'x-publishable-api-key': process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY as string,

View File

@ -122,7 +122,7 @@ export const CustomerProvider = ({ children }: CustomerProviderProps) => {
}; };
const getJwt = async (email: string, password: string) => { const getJwt = async (email: string, password: string) => {
try { 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', credentials: 'include',
method: 'POST', method: 'POST',
headers: { headers: {
@ -147,7 +147,7 @@ export const CustomerProvider = ({ children }: CustomerProviderProps) => {
}; };
const registerEmail = async (email: string, password: string) => { const registerEmail = async (email: string, password: string) => {
try { 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', credentials: 'include',
method: 'POST', method: 'POST',
headers: { headers: {
@ -176,7 +176,7 @@ export const CustomerProvider = ({ children }: CustomerProviderProps) => {
return; return;
} }
// get customer // 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', credentials: 'include',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
@ -198,7 +198,7 @@ export const CustomerProvider = ({ children }: CustomerProviderProps) => {
return; return;
} }
// create customer // 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', credentials: 'include',
method: 'POST', method: 'POST',
headers: { headers: {

View File

@ -28,7 +28,7 @@ export const RegionProvider = ({ children }: RegionProviderProps) => {
const regionId = localStorage.getItem('region_id'); const regionId = localStorage.getItem('region_id');
if (!regionId) { if (!regionId) {
// retrieve regions and select the first one // 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', credentials: 'include',
headers: { headers: {
'x-publishable-api-key': process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY as string, 'x-publishable-api-key': process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY as string,
@ -40,7 +40,7 @@ export const RegionProvider = ({ children }: RegionProviderProps) => {
}); });
} else { } else {
// retrieve selected region // 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', credentials: 'include',
headers: { headers: {
'x-publishable-api-key': process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY as string, 'x-publishable-api-key': process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY as string,