From 903f5982c26e11adddb86d426e3c870b54d247cc Mon Sep 17 00:00:00 2001 From: Shahed Nasser Date: Mon, 30 May 2022 10:51:06 +0300 Subject: [PATCH 1/4] docs: fix migrations --- docs/content/advanced/backend/migrations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/content/advanced/backend/migrations.md b/docs/content/advanced/backend/migrations.md index d838506eef..6fec10cb73 100644 --- a/docs/content/advanced/backend/migrations.md +++ b/docs/content/advanced/backend/migrations.md @@ -57,7 +57,7 @@ In this section, you’ll learn how to create your own migrations using [Typeorm To create a migration that makes changes to your Medusa schema, run the following command: ```bash -npx typeorm migration:create -n src/path/to/UserChanged +npx typeorm migration:create -n UserChanged --dir src/path ``` :::tip From 97f8ce39fc0fedcf0f611210e7dbd83d89f78318 Mon Sep 17 00:00:00 2001 From: Shahed Nasser Date: Mon, 30 May 2022 12:14:56 +0300 Subject: [PATCH 2/4] docs: fix for admin endpoints --- docs/content/advanced/backend/endpoints/add-admin.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/content/advanced/backend/endpoints/add-admin.md b/docs/content/advanced/backend/endpoints/add-admin.md index 3a85231e7f..65d9ff7117 100644 --- a/docs/content/advanced/backend/endpoints/add-admin.md +++ b/docs/content/advanced/backend/endpoints/add-admin.md @@ -66,11 +66,11 @@ const corsOptions = { } ``` -Finally, for each route you add, create an `OPTIONS` request: +Finally, for each route you add, create an `OPTIONS` request and add `cors` as a middleware for the route: ```js router.options("/admin/hello", cors(corsOptions)) -router.get("/admin/hello", (req, res) => { +router.get("/admin/hello", cors(corsOptions), (req, res) => { //... }) ``` From 8c00e9673a61f741fdc1c73136aa306548c3554e Mon Sep 17 00:00:00 2001 From: Shahed Nasser Date: Mon, 30 May 2022 12:48:20 +0300 Subject: [PATCH 3/4] docs: fix for storefront endpoints --- .../backend/endpoints/add-storefront.md | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/docs/content/advanced/backend/endpoints/add-storefront.md b/docs/content/advanced/backend/endpoints/add-storefront.md index 7f67980631..3782e0cb75 100644 --- a/docs/content/advanced/backend/endpoints/add-storefront.md +++ b/docs/content/advanced/backend/endpoints/add-storefront.md @@ -46,6 +46,34 @@ npm run build ::: +## Accessing Endpoints from Storefront + +If you’re customizing one of our storefronts or creating your own, you need to use the `cors` library. + +First, you need to import your Medusa’s configurations along with the `cors` library: + +```js +import cors from "cors" +import { projectConfig } from "../../medusa-config" +``` + +Then, create an object that will hold the CORS configurations: + +```js +const corsOptions = { + origin: projectConfig.store_cors.split(","), + credentials: true, +} +``` + +Finally, for each route add `cors` as a middleware for the route passing it `corsOptions`: + +```js +router.get("/admin/hello", cors(corsOptions), (req, res) => { + //... +}) +``` + ## Multiple Endpoints ### Same File From 527fa5eef102a12359fce86cb35345d3bd212a61 Mon Sep 17 00:00:00 2001 From: Shahed Nasser Date: Mon, 30 May 2022 12:49:46 +0300 Subject: [PATCH 4/4] change endpoint route --- docs/content/advanced/backend/endpoints/add-storefront.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/content/advanced/backend/endpoints/add-storefront.md b/docs/content/advanced/backend/endpoints/add-storefront.md index 3782e0cb75..adb738edbe 100644 --- a/docs/content/advanced/backend/endpoints/add-storefront.md +++ b/docs/content/advanced/backend/endpoints/add-storefront.md @@ -69,7 +69,7 @@ const corsOptions = { Finally, for each route add `cors` as a middleware for the route passing it `corsOptions`: ```js -router.get("/admin/hello", cors(corsOptions), (req, res) => { +router.get("/store/hello", cors(corsOptions), (req, res) => { //... }) ```