diff --git a/src/app/page.tsx b/src/app/page.tsx
index e4d5f54..188f982 100644
--- a/src/app/page.tsx
+++ b/src/app/page.tsx
@@ -1,11 +1,10 @@
import ProjectPage from "./projects/project-page";
import paramService, { ParamService } from "@/server/services/param.service";
-import HostnameCheck from "../components/custom/hostname-check";
+import HostnameCheck from "./settings/server/hostname-check";
export default async function Home() {
- const configuredDomain = await paramService.getString(ParamService.QS_SERVER_HOSTNAME);
return <>
-
+
>;
}
diff --git a/src/app/settings/server/actions.ts b/src/app/settings/server/actions.ts
index fefe019..c7e1653 100644
--- a/src/app/settings/server/actions.ts
+++ b/src/app/settings/server/actions.ts
@@ -1,10 +1,11 @@
'use server'
-import { getAuthUserSession, saveFormAction } from "@/server/utils/action-wrapper.utils";
+import { getAuthUserSession, saveFormAction, simpleAction } from "@/server/utils/action-wrapper.utils";
import paramService, { ParamService } from "@/server/services/param.service";
import { QsIngressSettingsModel, qsIngressSettingsZodModel } from "@/model/qs-settings.model";
import { QsLetsEncryptSettingsModel, qsLetsEncryptSettingsZodModel } from "@/model/qs-letsencrypt-settings.model";
import quickStackService from "@/server/services/qs.service";
+import { ServerActionResult } from "@/model/server-action-error-return.model";
export const updateIngressSettings = async (prevState: any, inputData: QsIngressSettingsModel) =>
saveFormAction(inputData, qsIngressSettingsZodModel, async (validatedData) => {
@@ -39,3 +40,10 @@ export const updateLetsEncryptSettings = async (prevState: any, inputData: QsLet
await quickStackService.createOrUpdateCertIssuer(validatedData.letsEncryptMail);
});
+
+export const getConfiguredHostname: () => Promise> = async () =>
+ simpleAction(async () => {
+ await getAuthUserSession();
+
+ return await paramService.getString(ParamService.QS_SERVER_HOSTNAME);
+ });
diff --git a/src/app/settings/server/hostname-check.tsx b/src/app/settings/server/hostname-check.tsx
new file mode 100644
index 0000000..c8768b0
--- /dev/null
+++ b/src/app/settings/server/hostname-check.tsx
@@ -0,0 +1,34 @@
+'use client'
+
+import { toast } from "sonner";
+import { useEffect } from "react";
+import { getConfiguredHostname } from "./actions";
+import { ExternalLink, Link } from "lucide-react";
+import { Button } from "@/components/ui/button";
+
+export default function HostnameCheck() {
+
+ const checkForCorrectHostname = async () => {
+ const configuredDomain = await getConfiguredHostname();
+ if (configuredDomain.status === 'success') {
+ const hostname = window.location.hostname;
+ const serverParamHostname = configuredDomain.data;
+ if (serverParamHostname && serverParamHostname !== hostname) {
+ toast.warning(`QuickStack is configured to run on a different domain. Please open the application on https://${serverParamHostname}`, {
+ duration: 10000,
+ action: {
+ label: ,
+ onClick: () => {
+ window.open(`https://${serverParamHostname}`, '_blank');
+ }
+ }
+ });
+ }
+ }
+ }
+
+ useEffect(() => {
+ checkForCorrectHostname();
+ });
+ return <>>;
+}
diff --git a/src/components/custom/hostname-check.tsx b/src/components/custom/hostname-check.tsx
deleted file mode 100644
index 40b5584..0000000
--- a/src/components/custom/hostname-check.tsx
+++ /dev/null
@@ -1,28 +0,0 @@
-'use client'
-
-import { Button } from "@/components/ui/button";
-import ProjectPage from "../../app/projects/project-page";
-import paramService, { ParamService } from "@/server/services/param.service";
-import { cookies } from "next/headers";
-import { toast } from "sonner";
-import { usePathname } from "next/navigation";
-import { useRouter } from "next/router";
-import { useEffect } from "react";
-
-export default function HostnameCheck({ serverParamHostname }: { serverParamHostname?: string }) {
- useEffect(() => {
- const hostname = window.location.hostname;
- if (serverParamHostname && serverParamHostname !== hostname) {
- toast.warning(`QuickStack is configured to run on a different domain. Please open the application on https://${serverParamHostname}`, {
- duration: 10000,
- action: {
- label: 'Open',
- onClick: () => {
- window.location.href = `https://${serverParamHostname}`;
- }
- }
- });
- }
- }, [serverParamHostname]);
- return <>>;
-}