From 6d80f4c098bdd62dd3f1cbb776d55e51915621ab Mon Sep 17 00:00:00 2001 From: Zhe Li Date: Fri, 31 Mar 2023 11:28:42 +0800 Subject: [PATCH] add domain redirect --- next.config.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/next.config.js b/next.config.js index fc164db9c..8a8602718 100644 --- a/next.config.js +++ b/next.config.js @@ -11,7 +11,27 @@ const nextConfig = { }); // 针对 SVG 的处理规则 return config; - } + }, + async redirects() { + if (!process.env.DOMAIN) { + return [] + } + + return [ + { + source: '/', + destination: `https://${process.env.DOMAIN}/`, + has: [ + { + type: 'host', + value: process.env.DOMAIN, + not: true + }, + ], + permanent: true, + }, + ] + }, }; if (process.env.DOCKER) {