Merge branch 'master' into develop
This commit is contained in:
@@ -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
|
```js
|
||||||
router.options("/admin/hello", cors(corsOptions))
|
router.options("/admin/hello", cors(corsOptions))
|
||||||
router.get("/admin/hello", (req, res) => {
|
router.get("/admin/hello", cors(corsOptions), (req, res) => {
|
||||||
//...
|
//...
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -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("/store/hello", cors(corsOptions), (req, res) => {
|
||||||
|
//...
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
## Multiple Endpoints
|
## Multiple Endpoints
|
||||||
|
|
||||||
### Same File
|
### Same File
|
||||||
|
|||||||
@@ -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:
|
To create a migration that makes changes to your Medusa schema, run the following command:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npx typeorm migration:create -n src/path/to/UserChanged
|
npx typeorm migration:create -n UserChanged --dir src/path
|
||||||
```
|
```
|
||||||
|
|
||||||
:::tip
|
:::tip
|
||||||
|
|||||||
Reference in New Issue
Block a user