diff --git a/docs/content/advanced/admin/import-prices.mdx b/docs/content/advanced/admin/import-prices.mdx index 7cbccf670f..bdfd44b305 100644 --- a/docs/content/advanced/admin/import-prices.mdx +++ b/docs/content/advanced/admin/import-prices.mdx @@ -79,6 +79,7 @@ formData.append('files', file); //file is an instance of File fetch(`/admin/uploads`, { method: 'POST', + credentials: 'include', headers: { 'Content-Type': 'multipart/form-data', }, @@ -134,6 +135,7 @@ medusa.admin.batchJobs.create({ ```jsx fetch(`/admin/batch-jobs`, { method: 'POST', + credentials: 'include', headers: { 'Content-Type': 'application/json' }, @@ -210,7 +212,9 @@ medusa.admin.batchJobs.retrieve(batchJobId) ```jsx -fetch(`/admin/batch-jobs/${batchJobId}`) +fetch(`/admin/batch-jobs/${batchJobId}`, { + credentials: 'include', +}) .then((response) => response.json()) .then(({ batch_job }) => { console.log(batch_job.status, batch_job.result); @@ -270,7 +274,8 @@ medusa.admin.batchJobs.confirm(batchJobId) ```jsx fetch(`/admin/batch-jobs/${batchJobId}/confirm`, { - method: 'POST' + method: 'POST', + credentials: 'include', }) .then((response) => response.json()) .then(({ batch_job }) => { diff --git a/docs/content/advanced/admin/import-products.mdx b/docs/content/advanced/admin/import-products.mdx index 347beb1af0..f70683129a 100644 --- a/docs/content/advanced/admin/import-products.mdx +++ b/docs/content/advanced/admin/import-products.mdx @@ -73,6 +73,7 @@ formData.append('files', file); //file is an instance of File fetch(`/admin/uploads`, { method: 'POST', + credentials: 'include', headers: { 'Content-Type': 'multipart/form-data', }, @@ -127,6 +128,7 @@ medusa.admin.batchJobs.create({ ```jsx fetch(`/admin/batch-jobs`, { method: 'POST', + credentials: 'include', headers: { 'Content-Type': 'application/json' }, @@ -198,7 +200,9 @@ medusa.admin.batchJobs.retrieve(batchJobId) ```jsx -fetch(`/admin/batch-jobs/${batchJobId}`) +fetch(`/admin/batch-jobs/${batchJobId}`, { + credentials: 'include', +}) .then((response) => response.json()) .then(({ batch_job }) => { console.log(batch_job.status, batch_job.result); @@ -258,7 +262,8 @@ medusa.admin.batchJobs.confirm(batchJobId) ```jsx fetch(`/admin/batch-jobs/${batchJobId}/confirm`, { - method: 'POST' + method: 'POST', + credentials: 'include', }) .then((response) => response.json()) .then(({ batch_job }) => { diff --git a/docs/content/advanced/admin/use-customergroups-api.mdx b/docs/content/advanced/admin/use-customergroups-api.mdx index ca44ec36df..8139c36bf4 100644 --- a/docs/content/advanced/admin/use-customergroups-api.mdx +++ b/docs/content/advanced/admin/use-customergroups-api.mdx @@ -57,6 +57,7 @@ medusa.admin.customerGroups.create({ ```jsx fetch(`/admin/customer-groups`, { method: 'POST', + credentials: 'include', headers: { 'Content-Type': 'application/json' }, @@ -107,7 +108,9 @@ medusa.admin.customerGroups.list() ```jsx -fetch(`/admin/customer-groups`) +fetch(`/admin/customer-groups`, { + credentials: 'include', +}) .then((response) => response.json()) .then(({ customer_groups, limit, offset, count }) => { console.log(customer_groups.length) @@ -149,7 +152,9 @@ medusa.admin.customerGroups.retrieve(customerGroupId) ```jsx -fetch(`/admin/customer-groups/${customerGroupId}`) +fetch(`/admin/customer-groups/${customerGroupId}`, { + credentials: 'include', +}) .then((response) => response.json()) .then(({ customer_group }) => { console.log(customer_group.id) @@ -195,6 +200,7 @@ medusa.admin.customerGroups.update(customerGroupId, { ```jsx fetch(`/admin/customer-groups/${customerGroupId}`, { method: 'POST', + credentials: 'include', headers: { 'Content-Type': 'application/json' }, @@ -250,7 +256,8 @@ medusa.admin.customerGroups.delete(customerGroupId) ```jsx fetch(`/admin/customer-groups/${customerGroupId}`, { - method: 'DELETE' + method: 'DELETE', + credentials: 'include', }) .then((response) => response.json()) .then(({ id, object, deleted }) => { @@ -301,6 +308,7 @@ medusa.admin.customerGroups.addCustomers(customerGroupId, { ```jsx fetch(`/admin/customer-groups/${customerGroupId}/customers/batch`, { method: 'POST', + credentials: 'include', headers: { 'Content-Type': 'application/json' }, @@ -357,7 +365,9 @@ medusa.admin.customerGroups.listCustomers(customerGroupId) ```jsx -fetch(`/admin/customer-groups/${customerGroupId}/customers`) +fetch(`/admin/customer-groups/${customerGroupId}/customers`, { + credentials: 'include', +}) .then((response) => response.json()) .then(({ customers, count, offset, limit }) => { console.log(customers.length) @@ -409,6 +419,7 @@ medusa.admin.customerGroups.removeCustomers(customer_group_id, { ```jsx fetch(`/admin/customer-groups/${customerGroupId}/customers/batch`, { method: 'DELETE', + credentials: 'include', headers: { 'Content-Type': 'application/json' }, diff --git a/docs/content/advanced/backend/batch-jobs/create.md b/docs/content/advanced/backend/batch-jobs/create.md index 02dc30c9a2..2eb536cc46 100644 --- a/docs/content/advanced/backend/batch-jobs/create.md +++ b/docs/content/advanced/backend/batch-jobs/create.md @@ -274,6 +274,7 @@ medusa.admin.batchJobs.create({ ```jsx fetch(`/admin/batch-jobs`, { method: 'POST', + credentials: 'include', headers: { 'Content-Type': 'application/json' }, @@ -328,7 +329,9 @@ medusa.admin.batchJobs.retrieve(batchJobId) ```jsx -fetch(`/admin/batch-jobs/${batchJobId}`) +fetch(`/admin/batch-jobs/${batchJobId}`, { + credentials: 'include', +}) .then((response) => response.json()) .then(({ batch_job }) => { console.log(batch_job.status, batch_job.result); @@ -382,7 +385,8 @@ medusa.admin.batchJobs.confirm(batchJobId) ```jsx fetch(`/admin/batch-jobs/${batchJobId}/confirm`, { - method: 'POST' + method: 'POST', + credentials: 'include', }) .then((response) => response.json()) .then(({ batch_job }) => { diff --git a/docs/content/advanced/backend/price-lists/use-api.mdx b/docs/content/advanced/backend/price-lists/use-api.mdx index e9a8d439b0..653142ec9a 100644 --- a/docs/content/advanced/backend/price-lists/use-api.mdx +++ b/docs/content/advanced/backend/price-lists/use-api.mdx @@ -100,6 +100,7 @@ medusa.admin.priceLists.create({ ```jsx fetch(`/admin/price-lists`, { method: 'POST', + credentials: 'include', headers: { 'Content-Type': 'application/json' }, @@ -186,7 +187,9 @@ medusa.admin.priceLists.retrieve(priceListId) ```jsx -fetch(`/admin/price-lists/${priceListId}`) +fetch(`/admin/price-lists/${priceListId}`, { + credentials: 'include', +}) .then((response) => response.json()) .then(({ price_list }) => { console.log(price_list.id) @@ -230,6 +233,7 @@ medusa.admin.priceLists.update(priceListId, { ```jsx fetch(`/admin/price-lists/${priceListId}`, { method: 'POST', + credentials: 'include', headers: { 'Content-Type': 'application/json' }, @@ -298,6 +302,7 @@ medusa.admin.priceLists.addPrices(priceListId, { ```jsx fetch(`/admin/price-lists/${priceListId}/prices/batch`, { method: 'POST', + credentials: 'include', headers: { 'Content-Type': 'application/json' }, @@ -361,7 +366,8 @@ medusa.admin.priceLists.deleteProductPrices(priceListId, productId) ```jsx fetch(`/admin/price-lists/${priceListId}/products/${productId}/prices`, { - method: 'DELETE' + method: 'DELETE', + credentials: 'include', }) .then((response) => response.json()) .then(({ ids, object, deleted }) => { @@ -401,7 +407,8 @@ medusa.admin.priceLists.deleteVariantPrices(priceListId, variantId) ```jsx fetch(`/admin/price-lists/${priceListId}/variants/${variantId}/prices`, { - method: 'DELETE' + method: 'DELETE', + credentials: 'include', }) .then((response) => response.json()) .then(({ ids, object, deleted }) => { @@ -443,7 +450,8 @@ medusa.admin.priceLists.delete(priceListId) ```jsx fetch(`/admin/price-lists/${priceListId}`, { - method: 'DELETE' + method: 'DELETE', + credentials: 'include', }) .then((response) => response.json()) .then(({ id, object, deleted }) => { diff --git a/docs/content/advanced/backend/sales-channels/manage-admin.mdx b/docs/content/advanced/backend/sales-channels/manage-admin.mdx index 7fa62dd578..126e07f26b 100644 --- a/docs/content/advanced/backend/sales-channels/manage-admin.mdx +++ b/docs/content/advanced/backend/sales-channels/manage-admin.mdx @@ -71,6 +71,7 @@ medusa.admin.salesChannels.create({ ```jsx fetch(`/admin/sales-channels`, { method: 'POST', + credentials: 'include', headers: { 'Content-Type': 'application/json' }, @@ -125,7 +126,9 @@ medusa.admin.salesChannels.list() ```jsx -fetch(`/admin/sales-channels`) +fetch(`/admin/sales-channels`, { + credentials: 'include', +}) .then((response) => response.json()) .then(({ sales_channels, limit, offset, count }) => { console.log(sales_channels.length) @@ -165,7 +168,9 @@ medusa.admin.salesChannels.retrieve(salesChannelId) ```jsx -fetch(`/admin/sales-channels/${salesChannelId}`) +fetch(`/admin/sales-channels/${salesChannelId}`, { + credentials: 'include', +}) .then((response) => response.json()) .then(({ sales_channels, limit, offset, count }) => { console.log(sales_channels.length) @@ -209,6 +214,7 @@ medusa.admin.salesChannels.update(salesChannelId, { ```jsx fetch(`/admin/sales-channels/${salesChannelId}`, { method: 'POST', + credentials: 'include', headers: { 'Content-Type': 'application/json' }, @@ -264,7 +270,8 @@ medusa.admin.salesChannels.delete(salesChannelId) ```jsx fetch(`/admin/sales-channels/${salesChannelId}`, { - method: 'DELETE' + method: 'DELETE', + credentials: 'include', }) .then((response) => response.json()) .then(({ id, object, deleted }) => { @@ -315,6 +322,7 @@ medusa.admin.salesChannels.addProducts(salesChannelId, { ```jsx fetch(`/admin/sales-channels/${salesChannelId}/products/batch`, { method: 'POST', + credentials: 'include', headers: { 'Content-Type': 'application/json' }, @@ -377,7 +385,9 @@ medusa.admin.products.list({ ```jsx -fetch(`/admin/products?sales_channel_id[0]=${salesChannelId}`) +fetch(`/admin/products?sales_channel_id[0]=${salesChannelId}`, { + credentials: 'include', +}) .then((response) => response.json()) .then(({ products, limit, offset, count }) => { console.log(products.length) @@ -429,6 +439,7 @@ medusa.admin.salesChannels.removeProducts(salesChannelId, { ```jsx fetch(`/admin/sales-channels/${salesChannelId}/products/batch`, { method: 'DELETE', + credentials: 'include', headers: { 'Content-Type': 'application/json' }, @@ -495,7 +506,9 @@ medusa.admin.orders.list({ ```jsx -fetch(`/admin/orders?sales_channel_id[0]=${salesChannelId}`) +fetch(`/admin/orders?sales_channel_id[0]=${salesChannelId}`, { + credentials: 'include', +}) .then((response) => response.json()) .then(({ orders, limit, offset, count }) => { console.log(orders.length) diff --git a/docs/content/advanced/storefront/how-to-implement-checkout-flow.mdx b/docs/content/advanced/storefront/how-to-implement-checkout-flow.mdx index 705b8ce047..7720badbb0 100644 --- a/docs/content/advanced/storefront/how-to-implement-checkout-flow.mdx +++ b/docs/content/advanced/storefront/how-to-implement-checkout-flow.mdx @@ -74,6 +74,7 @@ medusa.carts.update(cartId, { ```jsx fetch(`/store/carts/${cartId}`, { method: 'POST', + credentials: 'include', body: JSON.stringify({ shipping_address: { company, @@ -125,7 +126,9 @@ medusa.shippingOptions.listCartOptions(cartId) ```jsx -fetch(`/store/shipping-options/${cartId}`) +fetch(`/store/shipping-options/${cartId}`, { + credentials: 'include', +}) .then((response) => response.json()) .then(({ shipping_options }) => { console.log(shipping_options.length); @@ -159,6 +162,7 @@ medusa.carts.addShippingMethod(cartId, { ```jsx fetch(`/store/carts/${cartId}/shipping-methods`, { method: 'POST', + credentials: 'include', body: JSON.stringify({ option_id: shippingOptionId //the ID of the selected option }), @@ -204,7 +208,8 @@ medusa.carts.createPaymentSessions(cartId) ```jsx fetch(`/store/carts/${cartId}/payment-sessions`, { - method: 'POST' + method: 'POST', + credentials: 'include', }) .then((response) => response.json()) .then(({ cart }) => { @@ -239,6 +244,7 @@ medusa.carts.setPaymentSession(cartId, { ```jsx fetch(`/store/carts/${cartId}/payment-session`, { method: 'POST', + credentials: 'include', body: JSON.stringify({ provider_id: paymentProviderId // retrieved from the payment session selected by the customer }), @@ -293,6 +299,7 @@ medusa.carts.updatePaymentSession(cartId, paymentProviderId, { ```jsx fetch(`/store/carts/${cartId}/payment-sessions/${paymentProviderId}`, { method: 'POST', + credentials: 'include', body: JSON.stringify({ data: { //pass any data you want to add in the `data` attribute @@ -339,6 +346,7 @@ medusa.carts.complete(cartId) ```jsx fetch(`/store/carts/${cartId}/complete`, { method: 'POST', + credentials: 'include', headers: { 'Content-Type': 'application/json' } diff --git a/docs/content/guides/carts-in-medusa.mdx b/docs/content/guides/carts-in-medusa.mdx index 7940271eb2..3edf44438e 100644 --- a/docs/content/guides/carts-in-medusa.mdx +++ b/docs/content/guides/carts-in-medusa.mdx @@ -56,7 +56,8 @@ medusa.carts.create() ```jsx fetch(`/store/carts`, { - method: 'POST' + method: 'POST', + credentials: 'include', }) .then((response) => response.json()) .then(({ cart }) => { @@ -95,6 +96,7 @@ medusa.carts.create({ ```jsx fetch(`/store/carts`, { method: 'POST', + credentials: 'include', headers: { 'Content-Type': 'application/json' }, @@ -146,7 +148,9 @@ if (id) { const id = localStorage.getItem('cart_id'); if (id) { - fetch(`/store/carts/${id}`) + fetch(`/store/carts/${id}`, { + credentials: 'include', + }) .then((response) => response.json()) .then(({ cart }) => setCart(cart)); } @@ -187,6 +191,7 @@ medusa.carts.update(cartId, { ```jsx fetch(`/store/carts/${cartId}`, { method: 'POST', + credentials: 'include', headers: { 'Content-Type': 'application/json' }, @@ -229,6 +234,7 @@ medusa.carts.update(cartId, { ```jsx fetch(`/store/carts/${cartId}`, { method: 'POST', + credentials: 'include', headers: { 'Content-Type': 'application/json' }, @@ -267,6 +273,7 @@ medusa.carts.update(cartId, { ```jsx fetch(`/store/carts/${cartId}`, { method: 'POST', + credentials: 'include', headers: { 'Content-Type': 'application/json' }, @@ -302,6 +309,7 @@ medusa.carts.lineItems.create(cartId, { ```jsx fetch(`/store/carts/${cartId}/line-items`, { method: 'POST', + credentials: 'include', headers: { 'Content-Type': 'application/json' }, @@ -349,6 +357,7 @@ medusa.carts.lineItems.update(cartId, lineItemId, { ```jsx fetch(`/store/carts/${cartId}/line-items/${lineItemId}`, { method: 'POST', + credentials: 'include', headers: { 'Content-Type': 'application/json' }, @@ -384,7 +393,8 @@ medusa.carts.lineItems.delete(cartId, lineItemId) ```jsx fetch(`/store/carts/${cartId}/line-items/${lineItemId}`, { - method: 'DELETE' + method: 'DELETE', + credentials: 'include', }) .then((response) => response.json()) .then(({ cart }) => setCart(cart));