docs: changes for new releases + fixes (#12945)
* docs: changes for new releases + fixes * remove container option
This commit is contained in:
@@ -70,6 +70,87 @@ module.exports = defineConfig({
|
||||
|
||||
The `projectConfig` object contains essential configurations related to the Medusa application, such as database and CORS configurations.
|
||||
|
||||
### cookieOptions
|
||||
|
||||
<Note>
|
||||
|
||||
This option is available since Medusa [v2.8.5](https://github.com/medusajs/medusa/releases/tag/v2.8.5).
|
||||
|
||||
</Note>
|
||||
|
||||
The `projectConfig.cookieOptions` configuration defines cookie options to be passed to `express-session` when creating the session cookie. This configuration is useful when simulating a production environment locally, where you may need to set options like `secure` or `sameSite`.
|
||||
|
||||
#### Example
|
||||
|
||||
```ts title="medusa-config.ts"
|
||||
module.exports = defineConfig({
|
||||
projectConfig: {
|
||||
cookieOptions: {
|
||||
sameSite: "lax",
|
||||
},
|
||||
// ...
|
||||
},
|
||||
// ...
|
||||
})
|
||||
```
|
||||
|
||||
#### Properties
|
||||
|
||||
Aside from the following options, you can pass any property that the [express-session's cookie option accepts](https://www.npmjs.com/package/express-session).
|
||||
|
||||
<TypeList
|
||||
types={[
|
||||
{
|
||||
name: "secure",
|
||||
type: "`boolean`",
|
||||
description: `Whether the cookie should only be sent over HTTPS. This is useful in production environments where you want to ensure that cookies are only sent over secure connections.`,
|
||||
defaultValue: `false in development, true in production`
|
||||
},
|
||||
{
|
||||
name: "sameSite",
|
||||
type: "`lax` | `strict` | `none`",
|
||||
description: `Controls the SameSite attribute of the cookie.`,
|
||||
defaultValue: `"none" in production. In development, this attribute is not set.`
|
||||
},
|
||||
{
|
||||
name: "maxAge",
|
||||
type: "`number`",
|
||||
description: "The maximum age of the cookie in milliseconds set in the `Set-Cookie` header.",
|
||||
defaultValue: "Either the `sessionOptions.ttl` option, or `10` hours."
|
||||
},
|
||||
{
|
||||
name: "httpOnly",
|
||||
type: "`boolean`",
|
||||
description: "Whether to set the `HttpOnly Set-Cookie` attribute.",
|
||||
defaultValue: `true`
|
||||
},
|
||||
{
|
||||
name: "priority",
|
||||
type: "`low` \| `medium` \| `high`",
|
||||
description: "The value of the [Priority Set-Cookie attribute](https://tools.ietf.org/html/draft-west-cookie-priority-00#section-4.1)",
|
||||
defaultValue: `medium`
|
||||
},
|
||||
{
|
||||
name: "domain",
|
||||
type: "`string`",
|
||||
description: "The value of the `Domain Set-Cookie` attribute. By default, no domain is set, and most clients will consider the cookie to apply to the current domain only."
|
||||
},
|
||||
{
|
||||
name: "path",
|
||||
type: "`string`",
|
||||
description: "The value of the `Path Set-Cookie` attribute",
|
||||
defaultValue: `/`
|
||||
},
|
||||
{
|
||||
name: "signed",
|
||||
type: "`boolean`",
|
||||
description: "Whether to sign the cookie.",
|
||||
defaultValue: `true`
|
||||
}
|
||||
]}
|
||||
openedLevel={1}
|
||||
/>
|
||||
|
||||
### databaseDriverOptions
|
||||
|
||||
The `projectConfig.databaseDriverOptions` configuration is an object of additional options used to configure the PostgreSQL connection. For example, you can support TLS/SSL connection using this configuration's `ssl` property.
|
||||
|
||||
@@ -45,7 +45,7 @@ The API routes that restrict the fields and relations you can retrieve are:
|
||||
|
||||
### How to Override Allowed Fields and Relations
|
||||
|
||||
For these routes, you need to override the allowed fields and relations to be retrieved. You can do this by adding a [middleware](../middlewares/page.mdx) to those routes.
|
||||
For these routes, you need to override the allowed fields and relations to be retrieved. You can do this by applying a [global middleware](../middlewares/page.mdx) to those routes.
|
||||
|
||||
For example, to allow retrieving the `b2b_company` of a customer using the [Get Customer Admin API Route](!api!/admin#customers_getcustomersid), create the file `src/api/middlewares.ts` with the following content:
|
||||
|
||||
@@ -66,10 +66,9 @@ export default defineMiddlewares({
|
||||
routes: [
|
||||
{
|
||||
matcher: "/store/customers/me",
|
||||
method: "GET",
|
||||
middlewares: [
|
||||
(req, res, next) => {
|
||||
req.allowed?.push("b2b_company")
|
||||
(req.allowed ??= []).push("b2b_company")
|
||||
next()
|
||||
},
|
||||
],
|
||||
@@ -90,3 +89,9 @@ curl 'http://localhost:9000/admin/customers/{id}?fields=*b2b_company' \
|
||||
```
|
||||
|
||||
In this example, you retrieve the `b2b_company` relation of the customer using the `fields` query parameter.
|
||||
|
||||
<Note title="Important">
|
||||
|
||||
This approach only works using a global middleware. It doesn't work in a route middleware.
|
||||
|
||||
</Note>
|
||||
@@ -151,9 +151,6 @@ export const setStepSuccessStep = createStep(
|
||||
workflowId: "hello-world",
|
||||
},
|
||||
stepResponse: new StepResponse("Done!"),
|
||||
options: {
|
||||
container,
|
||||
},
|
||||
})
|
||||
}
|
||||
)
|
||||
@@ -203,20 +200,6 @@ The `setStepSuccess` method of the workflow engine's main service accepts as a p
|
||||
description: "Set the response of the step. This is similar to the response you return in a step's definition, but since the `async` step doesn't have a response, you set its response when changing its status.",
|
||||
optional: false
|
||||
},
|
||||
{
|
||||
name: "options",
|
||||
type: "`Record<string, any>`",
|
||||
description: "Options to pass to the step.",
|
||||
optional: true,
|
||||
children: [
|
||||
{
|
||||
name: "container",
|
||||
type: "`MedusaContainer`",
|
||||
description: "An instance of the Medusa Container",
|
||||
optional: true
|
||||
}
|
||||
]
|
||||
}
|
||||
]}
|
||||
/>
|
||||
|
||||
@@ -269,9 +252,6 @@ export const setStepFailureStep = createStep(
|
||||
workflowId: "hello-world",
|
||||
},
|
||||
stepResponse: new StepResponse("Failed!"),
|
||||
options: {
|
||||
container,
|
||||
},
|
||||
})
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user