From 8ec488efbd056ba906ce9e886ea0077622f8481a Mon Sep 17 00:00:00 2001
From: shamoon <4887959+shamoon@users.noreply.github.com>
Date: Wed, 18 Oct 2023 11:44:26 -0700
Subject: [PATCH] Revert "Fix: subdirectory deployment (#2205)"
This revers commit b8eda91005f389eb2d907b8b56494b4f6df03447
---
next.config.js | 1 -
src/components/services/ping.jsx | 2 +-
src/components/services/status.jsx | 2 +-
src/components/toggles/revalidate.jsx | 2 +-
src/components/version.jsx | 2 +-
src/components/widgets/glances/glances.jsx | 2 +-
.../widgets/kubernetes/kubernetes.jsx | 2 +-
src/components/widgets/longhorn/longhorn.jsx | 2 +-
.../widgets/openmeteo/openmeteo.jsx | 2 +-
.../widgets/openweathermap/weather.jsx | 2 +-
src/components/widgets/resources/cpu.jsx | 2 +-
src/components/widgets/resources/cputemp.jsx | 2 +-
src/components/widgets/resources/disk.jsx | 2 +-
src/components/widgets/resources/memory.jsx | 2 +-
src/components/widgets/resources/uptime.jsx | 2 +-
src/components/widgets/weather/weather.jsx | 2 +-
src/pages/_document.jsx | 4 +-
src/pages/index.jsx | 40 +++++++++----------
src/utils/proxy/api-helpers.js | 4 +-
src/widgets/docker/component.jsx | 4 +-
20 files changed, 41 insertions(+), 42 deletions(-)
diff --git a/next.config.js b/next.config.js
index acdf704d..dae78ca0 100644
--- a/next.config.js
+++ b/next.config.js
@@ -2,7 +2,6 @@ const { i18n } = require("./next-i18next.config");
/** @type {import('next').NextConfig} */
const nextConfig = {
- assetPrefix: ".",
reactStrictMode: true,
output: "standalone",
swcMinify: false,
diff --git a/src/components/services/ping.jsx b/src/components/services/ping.jsx
index ca250450..cdaec08d 100644
--- a/src/components/services/ping.jsx
+++ b/src/components/services/ping.jsx
@@ -3,7 +3,7 @@ import useSWR from "swr";
export default function Ping({ group, service, style }) {
const { t } = useTranslation();
- const { data, error } = useSWR(`api/ping?${new URLSearchParams({ group, service }).toString()}`, {
+ const { data, error } = useSWR(`/api/ping?${new URLSearchParams({ group, service }).toString()}`, {
refreshInterval: 30000,
});
diff --git a/src/components/services/status.jsx b/src/components/services/status.jsx
index da120ce2..e0f74210 100644
--- a/src/components/services/status.jsx
+++ b/src/components/services/status.jsx
@@ -4,7 +4,7 @@ import useSWR from "swr";
export default function Status({ service, style }) {
const { t } = useTranslation();
- const { data, error } = useSWR(`api/docker/status/${service.container}/${service.server || ""}`);
+ const { data, error } = useSWR(`/api/docker/status/${service.container}/${service.server || ""}`);
let statusLabel = t("docker.unknown");
let statusTitle = "";
diff --git a/src/components/toggles/revalidate.jsx b/src/components/toggles/revalidate.jsx
index c17f4abe..14fe8b37 100644
--- a/src/components/toggles/revalidate.jsx
+++ b/src/components/toggles/revalidate.jsx
@@ -2,7 +2,7 @@ import { MdRefresh } from "react-icons/md";
export default function Revalidate() {
const revalidate = () => {
- fetch("api/revalidate").then((res) => {
+ fetch("/api/revalidate").then((res) => {
if (res.ok) {
window.location.reload();
}
diff --git a/src/components/version.jsx b/src/components/version.jsx
index d2652f96..5c0b82b6 100644
--- a/src/components/version.jsx
+++ b/src/components/version.jsx
@@ -12,7 +12,7 @@ export default function Version() {
const revision = process.env.NEXT_PUBLIC_REVISION?.length ? process.env.NEXT_PUBLIC_REVISION : "dev";
const version = process.env.NEXT_PUBLIC_VERSION?.length ? process.env.NEXT_PUBLIC_VERSION : "dev";
- const { data: releaseData } = useSWR("api/releases");
+ const { data: releaseData } = useSWR("/api/releases");
// use Intl.DateTimeFormat to format the date
const formatDate = (date) => {
diff --git a/src/components/widgets/glances/glances.jsx b/src/components/widgets/glances/glances.jsx
index 4bb8184f..0834b775 100644
--- a/src/components/widgets/glances/glances.jsx
+++ b/src/components/widgets/glances/glances.jsx
@@ -23,7 +23,7 @@ export default function Widget({ options }) {
const { settings } = useContext(SettingsContext);
const { data, error } = useSWR(
- `api/widgets/glances?${new URLSearchParams({ lang: i18n.language, ...options }).toString()}`,
+ `/api/widgets/glances?${new URLSearchParams({ lang: i18n.language, ...options }).toString()}`,
{
refreshInterval: 1500,
},
diff --git a/src/components/widgets/kubernetes/kubernetes.jsx b/src/components/widgets/kubernetes/kubernetes.jsx
index 91128020..f7b101c7 100644
--- a/src/components/widgets/kubernetes/kubernetes.jsx
+++ b/src/components/widgets/kubernetes/kubernetes.jsx
@@ -25,7 +25,7 @@ export default function Widget({ options }) {
},
};
- const { data, error } = useSWR(`api/widgets/kubernetes?${new URLSearchParams({ lang: i18n.language }).toString()}`, {
+ const { data, error } = useSWR(`/api/widgets/kubernetes?${new URLSearchParams({ lang: i18n.language }).toString()}`, {
refreshInterval: 1500,
});
diff --git a/src/components/widgets/longhorn/longhorn.jsx b/src/components/widgets/longhorn/longhorn.jsx
index e0872b57..22047e2c 100644
--- a/src/components/widgets/longhorn/longhorn.jsx
+++ b/src/components/widgets/longhorn/longhorn.jsx
@@ -8,7 +8,7 @@ import Node from "./node";
export default function Longhorn({ options }) {
const { expanded, total, labels, include, nodes } = options;
- const { data, error } = useSWR(`api/widgets/longhorn`, {
+ const { data, error } = useSWR(`/api/widgets/longhorn`, {
refreshInterval: 1500,
});
diff --git a/src/components/widgets/openmeteo/openmeteo.jsx b/src/components/widgets/openmeteo/openmeteo.jsx
index aaee7918..8baddfa5 100644
--- a/src/components/widgets/openmeteo/openmeteo.jsx
+++ b/src/components/widgets/openmeteo/openmeteo.jsx
@@ -15,7 +15,7 @@ import mapIcon from "../../../utils/weather/openmeteo-condition-map";
function Widget({ options }) {
const { t } = useTranslation();
- const { data, error } = useSWR(`api/widgets/openmeteo?${new URLSearchParams({ ...options }).toString()}`);
+ const { data, error } = useSWR(`/api/widgets/openmeteo?${new URLSearchParams({ ...options }).toString()}`);
if (error || data?.error) {
return ;
diff --git a/src/components/widgets/openweathermap/weather.jsx b/src/components/widgets/openweathermap/weather.jsx
index 2c51ba0f..7b442990 100644
--- a/src/components/widgets/openweathermap/weather.jsx
+++ b/src/components/widgets/openweathermap/weather.jsx
@@ -16,7 +16,7 @@ function Widget({ options }) {
const { t, i18n } = useTranslation();
const { data, error } = useSWR(
- `api/widgets/openweathermap?${new URLSearchParams({ lang: i18n.language, ...options }).toString()}`,
+ `/api/widgets/openweathermap?${new URLSearchParams({ lang: i18n.language, ...options }).toString()}`,
);
if (error || data?.cod === 401 || data?.error) {
diff --git a/src/components/widgets/resources/cpu.jsx b/src/components/widgets/resources/cpu.jsx
index 4e1128ec..1963637d 100644
--- a/src/components/widgets/resources/cpu.jsx
+++ b/src/components/widgets/resources/cpu.jsx
@@ -8,7 +8,7 @@ import Error from "../widget/error";
export default function Cpu({ expanded, refresh = 1500 }) {
const { t } = useTranslation();
- const { data, error } = useSWR(`api/widgets/resources?type=cpu`, {
+ const { data, error } = useSWR(`/api/widgets/resources?type=cpu`, {
refreshInterval: refresh,
});
diff --git a/src/components/widgets/resources/cputemp.jsx b/src/components/widgets/resources/cputemp.jsx
index 20b377f1..96f98096 100644
--- a/src/components/widgets/resources/cputemp.jsx
+++ b/src/components/widgets/resources/cputemp.jsx
@@ -12,7 +12,7 @@ function convertToFahrenheit(t) {
export default function CpuTemp({ expanded, units, refresh = 1500 }) {
const { t } = useTranslation();
- const { data, error } = useSWR(`api/widgets/resources?type=cputemp`, {
+ const { data, error } = useSWR(`/api/widgets/resources?type=cputemp`, {
refreshInterval: refresh,
});
diff --git a/src/components/widgets/resources/disk.jsx b/src/components/widgets/resources/disk.jsx
index 0660063c..4cc86afb 100644
--- a/src/components/widgets/resources/disk.jsx
+++ b/src/components/widgets/resources/disk.jsx
@@ -8,7 +8,7 @@ import Error from "../widget/error";
export default function Disk({ options, expanded, refresh = 1500 }) {
const { t } = useTranslation();
- const { data, error } = useSWR(`api/widgets/resources?type=disk&target=${options.disk}`, {
+ const { data, error } = useSWR(`/api/widgets/resources?type=disk&target=${options.disk}`, {
refreshInterval: refresh,
});
diff --git a/src/components/widgets/resources/memory.jsx b/src/components/widgets/resources/memory.jsx
index b25c8261..155b7ecb 100644
--- a/src/components/widgets/resources/memory.jsx
+++ b/src/components/widgets/resources/memory.jsx
@@ -8,7 +8,7 @@ import Error from "../widget/error";
export default function Memory({ expanded, refresh = 1500 }) {
const { t } = useTranslation();
- const { data, error } = useSWR(`api/widgets/resources?type=memory`, {
+ const { data, error } = useSWR(`/api/widgets/resources?type=memory`, {
refreshInterval: refresh,
});
diff --git a/src/components/widgets/resources/uptime.jsx b/src/components/widgets/resources/uptime.jsx
index d89c5e8a..72b4865f 100644
--- a/src/components/widgets/resources/uptime.jsx
+++ b/src/components/widgets/resources/uptime.jsx
@@ -8,7 +8,7 @@ import Error from "../widget/error";
export default function Uptime({ refresh = 1500 }) {
const { t } = useTranslation();
- const { data, error } = useSWR(`api/widgets/resources?type=uptime`, {
+ const { data, error } = useSWR(`/api/widgets/resources?type=uptime`, {
refreshInterval: refresh,
});
diff --git a/src/components/widgets/weather/weather.jsx b/src/components/widgets/weather/weather.jsx
index c6ea2767..08074ee5 100644
--- a/src/components/widgets/weather/weather.jsx
+++ b/src/components/widgets/weather/weather.jsx
@@ -16,7 +16,7 @@ function Widget({ options }) {
const { t, i18n } = useTranslation();
const { data, error } = useSWR(
- `api/widgets/weather?${new URLSearchParams({ lang: i18n.language, ...options }).toString()}`,
+ `/api/widgets/weather?${new URLSearchParams({ lang: i18n.language, ...options }).toString()}`,
);
if (error || data?.error) {
diff --git a/src/pages/_document.jsx b/src/pages/_document.jsx
index 0698f6ca..c9a6c29e 100644
--- a/src/pages/_document.jsx
+++ b/src/pages/_document.jsx
@@ -9,8 +9,8 @@ export default function Document() {
content="A highly customizable homepage (or startpage / application dashboard) with Docker and service API integrations."
/>
-
-
+
+
diff --git a/src/pages/index.jsx b/src/pages/index.jsx
index 5053e087..4b922ccf 100644
--- a/src/pages/index.jsx
+++ b/src/pages/index.jsx
@@ -56,10 +56,10 @@ export async function getStaticProps() {
props: {
initialSettings: settings,
fallback: {
- "api/services": services,
- "api/bookmarks": bookmarks,
- "api/widgets": widgets,
- "api/hash": false,
+ "/api/services": services,
+ "/api/bookmarks": bookmarks,
+ "/api/widgets": widgets,
+ "/api/hash": false,
},
...(await serverSideTranslations(settings.language ?? "en")),
},
@@ -72,10 +72,10 @@ export async function getStaticProps() {
props: {
initialSettings: {},
fallback: {
- "api/services": [],
- "api/bookmarks": [],
- "api/widgets": [],
- "api/hash": false,
+ "/api/services": [],
+ "/api/bookmarks": [],
+ "/api/widgets": [],
+ "/api/hash": false,
},
...(await serverSideTranslations("en")),
},
@@ -86,8 +86,8 @@ export async function getStaticProps() {
function Index({ initialSettings, fallback }) {
const windowFocused = useWindowFocus();
const [stale, setStale] = useState(false);
- const { data: errorsData } = useSWR("api/validate");
- const { data: hashData, mutate: mutateHash } = useSWR("api/hash");
+ const { data: errorsData } = useSWR("/api/validate");
+ const { data: hashData, mutate: mutateHash } = useSWR("/api/hash");
useEffect(() => {
if (windowFocused) {
@@ -108,7 +108,7 @@ function Index({ initialSettings, fallback }) {
setStale(true);
localStorage.setItem("hash", hashData.hash);
- fetch("api/revalidate").then((res) => {
+ fetch("/api/revalidate").then((res) => {
if (res.ok) {
window.location.reload();
}
@@ -179,9 +179,9 @@ function Home({ initialSettings }) {
setSettings(initialSettings);
}, [initialSettings, setSettings]);
- const { data: services } = useSWR("api/services");
- const { data: bookmarks } = useSWR("api/bookmarks");
- const { data: widgets } = useSWR("api/widgets");
+ const { data: services } = useSWR("/api/services");
+ const { data: bookmarks } = useSWR("/api/bookmarks");
+ const { data: widgets } = useSWR("/api/widgets");
const servicesAndBookmarks = [
...services.map((sg) => sg.services).flat(),
@@ -368,17 +368,17 @@ function Home({ initialSettings }) {
>
) : (
<>
-
-
-
-
+
+
+
+
>
)}
-
+
-
+
diff --git a/src/utils/proxy/api-helpers.js b/src/utils/proxy/api-helpers.js
index 4dc1cd69..cfb4307e 100644
--- a/src/utils/proxy/api-helpers.js
+++ b/src/utils/proxy/api-helpers.js
@@ -23,7 +23,7 @@ export function formatProxyUrlWithSegments(widget, endpoint, segments) {
if (segments) {
params.append("segments", JSON.stringify(segments));
}
- return `api/services/proxy?${params.toString()}`;
+ return `/api/services/proxy?${params.toString()}`;
}
export function formatProxyUrl(widget, endpoint, queryParams) {
@@ -31,7 +31,7 @@ export function formatProxyUrl(widget, endpoint, queryParams) {
if (queryParams) {
params.append("query", JSON.stringify(queryParams));
}
- return `api/services/proxy?${params.toString()}`;
+ return `/api/services/proxy?${params.toString()}`;
}
export function asJson(data) {
diff --git a/src/widgets/docker/component.jsx b/src/widgets/docker/component.jsx
index 15b20420..c88ef8f6 100644
--- a/src/widgets/docker/component.jsx
+++ b/src/widgets/docker/component.jsx
@@ -12,10 +12,10 @@ export default function Component({ service }) {
const { widget } = service;
const { data: statusData, error: statusError } = useSWR(
- `api/docker/status/${widget.container}/${widget.server || ""}`,
+ `/api/docker/status/${widget.container}/${widget.server || ""}`,
);
- const { data: statsData, error: statsError } = useSWR(`api/docker/stats/${widget.container}/${widget.server || ""}`);
+ const { data: statsData, error: statsError } = useSWR(`/api/docker/stats/${widget.container}/${widget.server || ""}`);
if (statsError || statsData?.error || statusError || statusData?.error) {
const finalError = statsError ?? statsData?.error ?? statusError ?? statusData?.error;