From 4467ba3acab2e7abda9ecddf10373fd654063c1e Mon Sep 17 00:00:00 2001 From: Hoang Vo Date: Thu, 23 Sep 2021 02:44:51 +0700 Subject: [PATCH] Only config CLOUDINARY_URL if defined --- pages/api/user/index.js | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/pages/api/user/index.js b/pages/api/user/index.js index a1f1317..dd96246 100644 --- a/pages/api/user/index.js +++ b/pages/api/user/index.js @@ -9,18 +9,19 @@ import nc from 'next-connect'; const upload = multer({ dest: '/tmp' }); const handler = nc(ncOpts); -/* eslint-disable camelcase */ -const { - hostname: cloud_name, - username: api_key, - password: api_secret, -} = new URL(process.env.CLOUDINARY_URL); +if (process.env.CLOUDINARY_URL) { + const { + hostname: cloud_name, + username: api_key, + password: api_secret, + } = new URL(process.env.CLOUDINARY_URL); -cloudinary.config({ - cloud_name, - api_key, - api_secret, -}); + cloudinary.config({ + cloud_name, + api_key, + api_secret, + }); +} handler.use(all);