From 745dbd9491a078dc0b9c19d4925fed691ae2be85 Mon Sep 17 00:00:00 2001 From: Roy Li Date: Tue, 19 Sep 2023 22:34:59 +0200 Subject: [PATCH] fix: https://community.nssurge.com/d/2037-nginx-web-dashboard-v201 --- src/components/PageLayout/index.tsx | 4 ++-- src/pages/Landing/Regular.tsx | 2 +- src/pages/Landing/utils.ts | 12 +++++++++--- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/components/PageLayout/index.tsx b/src/components/PageLayout/index.tsx index f774009..4839e51 100644 --- a/src/components/PageLayout/index.tsx +++ b/src/components/PageLayout/index.tsx @@ -15,8 +15,8 @@ const PageLayout: React.FC> = ({ )} {...props} > -
-
+
+
{children}
diff --git a/src/pages/Landing/Regular.tsx b/src/pages/Landing/Regular.tsx index 3600826..634b1ce 100644 --- a/src/pages/Landing/Regular.tsx +++ b/src/pages/Landing/Regular.tsx @@ -97,7 +97,7 @@ const Page: React.FC = () => { const surgeHost = getSurgeHost() const protocol = data.useTls ? 'https:' : 'http:' - let newProfile: any + let newProfile try { const res = await tryHost(protocol, data.host, data.port, data.key) diff --git a/src/pages/Landing/utils.ts b/src/pages/Landing/utils.ts index 588f0ae..6684dd6 100644 --- a/src/pages/Landing/utils.ts +++ b/src/pages/Landing/utils.ts @@ -50,15 +50,21 @@ export const getSurgeHost = (): { hostname: string port: string } => { - const protocol = window.location.protocol + if (process.env.NODE_ENV !== 'production') { + const protocol = window.location.protocol + const port = window.location.port + ? window.location.port + : protocol === 'https:' + ? '443' + : '80' - if (process.env.NODE_ENV === 'production') { return { protocol, hostname: window.location.hostname, - port: window.location.port, + port, } } + return { protocol: process.env.REACT_APP_PROTOCOL as string, hostname: process.env.REACT_APP_HOST as string,