From 524b71507ff623478b970d8437b452bcb58d5609 Mon Sep 17 00:00:00 2001 From: chrismarsh-hhl <160502695+chrismarsh-hhl@users.noreply.github.com> Date: Fri, 27 Sep 2024 11:10:22 +0100 Subject: [PATCH] feat: use runtimeConfig to set options (#250) Nuxt allows you to use environment variables through useRuntimeConfig. This is preferable when you want different settings in different environments, and want to use secrets (e.g. SMTP username and password) without exposing them in nuxt.config.ts. This change adds `runtimeConfig.mail` options to the options object. fix #120 --- src/index.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 467fd27..1c2946b 100644 --- a/src/index.js +++ b/src/index.js @@ -22,7 +22,14 @@ const moduleName = parsePackagejsonName(packageConfig.name).fullName; export default function (moduleOptions, nuxt) { nuxt = nuxt || this; - const options = { ...nuxt.options.mail, ...moduleOptions }; + + const runtimeConfig = useRuntimeConfig(); + + const options = { + ...runtimeConfig.mail, + ...nuxt.options.mail, + ...moduleOptions, + }; if (!options.smtp) { throw new Error('SMTP config is missing.');