From bd60efbe6578dce9a508c5885e9d3ce4f86c8f09 Mon Sep 17 00:00:00 2001 From: Sujal Gurung <86787475+dinesh-58@users.noreply.github.com> Date: Mon, 18 Dec 2023 18:12:10 +0545 Subject: [PATCH] docs: set rejectUnauthorized based on condition (#5907) The general guide for hosting the server tells users to set `ssl.rejectUnauthorized` to false for production environments. However, the provided code snippet doesn't check the environment while setting the value. Directly pasting it into `medusa-config.js` will cause database connection attempts made from a development environment to be rejected and you can't even login to the admin account. The change only sets the ssl property to false if the environment is a non-development one. ~I got this code suggestion from the Kapa bot on discord so not sure if this is the best way to do this.~ This code is taken from the [configuration docs](https://docs.medusajs.com/development/backend/configurations#database_extra) themselves. Co-authored-by: Shahed Nasser <27354907+shahednasser@users.noreply.github.com> --- www/apps/docs/content/deployments/server/general-guide.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/www/apps/docs/content/deployments/server/general-guide.md b/www/apps/docs/content/deployments/server/general-guide.md index db4e982b9c..c1b1c914bd 100644 --- a/www/apps/docs/content/deployments/server/general-guide.md +++ b/www/apps/docs/content/deployments/server/general-guide.md @@ -39,7 +39,12 @@ In production, it’s recommended to set the [database_extra option](../../devel module.exports = { projectConfig: { // ... - database_extra: { ssl: { rejectUnauthorized: false } }, + database_extra: process.env.NODE_ENV !== "development" ? + { + ssl: { + rejectUnauthorized: false, + }, + } : {}, }, } ```