Revert "Fix: subdirectory deployment (#2205)"

This revers commit b8eda91005
pull/2209/head v0.7.4
shamoon 1 year ago
parent 9e3bc8e64f
commit 8ec488efbd

@ -2,7 +2,6 @@ const { i18n } = require("./next-i18next.config");
/** @type {import('next').NextConfig} */ /** @type {import('next').NextConfig} */
const nextConfig = { const nextConfig = {
assetPrefix: ".",
reactStrictMode: true, reactStrictMode: true,
output: "standalone", output: "standalone",
swcMinify: false, swcMinify: false,

@ -3,7 +3,7 @@ import useSWR from "swr";
export default function Ping({ group, service, style }) { export default function Ping({ group, service, style }) {
const { t } = useTranslation(); 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, refreshInterval: 30000,
}); });

@ -4,7 +4,7 @@ import useSWR from "swr";
export default function Status({ service, style }) { export default function Status({ service, style }) {
const { t } = useTranslation(); 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 statusLabel = t("docker.unknown");
let statusTitle = ""; let statusTitle = "";

@ -2,7 +2,7 @@ import { MdRefresh } from "react-icons/md";
export default function Revalidate() { export default function Revalidate() {
const revalidate = () => { const revalidate = () => {
fetch("api/revalidate").then((res) => { fetch("/api/revalidate").then((res) => {
if (res.ok) { if (res.ok) {
window.location.reload(); window.location.reload();
} }

@ -12,7 +12,7 @@ export default function Version() {
const revision = process.env.NEXT_PUBLIC_REVISION?.length ? process.env.NEXT_PUBLIC_REVISION : "dev"; 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 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 // use Intl.DateTimeFormat to format the date
const formatDate = (date) => { const formatDate = (date) => {

@ -23,7 +23,7 @@ export default function Widget({ options }) {
const { settings } = useContext(SettingsContext); const { settings } = useContext(SettingsContext);
const { data, error } = useSWR( 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, refreshInterval: 1500,
}, },

@ -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, refreshInterval: 1500,
}); });

@ -8,7 +8,7 @@ import Node from "./node";
export default function Longhorn({ options }) { export default function Longhorn({ options }) {
const { expanded, total, labels, include, nodes } = options; const { expanded, total, labels, include, nodes } = options;
const { data, error } = useSWR(`api/widgets/longhorn`, { const { data, error } = useSWR(`/api/widgets/longhorn`, {
refreshInterval: 1500, refreshInterval: 1500,
}); });

@ -15,7 +15,7 @@ import mapIcon from "../../../utils/weather/openmeteo-condition-map";
function Widget({ options }) { function Widget({ options }) {
const { t } = useTranslation(); 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) { if (error || data?.error) {
return <Error options={options} />; return <Error options={options} />;

@ -16,7 +16,7 @@ function Widget({ options }) {
const { t, i18n } = useTranslation(); const { t, i18n } = useTranslation();
const { data, error } = useSWR( 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) { if (error || data?.cod === 401 || data?.error) {

@ -8,7 +8,7 @@ import Error from "../widget/error";
export default function Cpu({ expanded, refresh = 1500 }) { export default function Cpu({ expanded, refresh = 1500 }) {
const { t } = useTranslation(); const { t } = useTranslation();
const { data, error } = useSWR(`api/widgets/resources?type=cpu`, { const { data, error } = useSWR(`/api/widgets/resources?type=cpu`, {
refreshInterval: refresh, refreshInterval: refresh,
}); });

@ -12,7 +12,7 @@ function convertToFahrenheit(t) {
export default function CpuTemp({ expanded, units, refresh = 1500 }) { export default function CpuTemp({ expanded, units, refresh = 1500 }) {
const { t } = useTranslation(); const { t } = useTranslation();
const { data, error } = useSWR(`api/widgets/resources?type=cputemp`, { const { data, error } = useSWR(`/api/widgets/resources?type=cputemp`, {
refreshInterval: refresh, refreshInterval: refresh,
}); });

@ -8,7 +8,7 @@ import Error from "../widget/error";
export default function Disk({ options, expanded, refresh = 1500 }) { export default function Disk({ options, expanded, refresh = 1500 }) {
const { t } = useTranslation(); 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, refreshInterval: refresh,
}); });

@ -8,7 +8,7 @@ import Error from "../widget/error";
export default function Memory({ expanded, refresh = 1500 }) { export default function Memory({ expanded, refresh = 1500 }) {
const { t } = useTranslation(); const { t } = useTranslation();
const { data, error } = useSWR(`api/widgets/resources?type=memory`, { const { data, error } = useSWR(`/api/widgets/resources?type=memory`, {
refreshInterval: refresh, refreshInterval: refresh,
}); });

@ -8,7 +8,7 @@ import Error from "../widget/error";
export default function Uptime({ refresh = 1500 }) { export default function Uptime({ refresh = 1500 }) {
const { t } = useTranslation(); const { t } = useTranslation();
const { data, error } = useSWR(`api/widgets/resources?type=uptime`, { const { data, error } = useSWR(`/api/widgets/resources?type=uptime`, {
refreshInterval: refresh, refreshInterval: refresh,
}); });

@ -16,7 +16,7 @@ function Widget({ options }) {
const { t, i18n } = useTranslation(); const { t, i18n } = useTranslation();
const { data, error } = useSWR( 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) { if (error || data?.error) {

@ -9,8 +9,8 @@ export default function Document() {
content="A highly customizable homepage (or startpage / application dashboard) with Docker and service API integrations." content="A highly customizable homepage (or startpage / application dashboard) with Docker and service API integrations."
/> />
<meta name="apple-mobile-web-app-capable" content="yes" /> <meta name="apple-mobile-web-app-capable" content="yes" />
<link rel="manifest" href="site.webmanifest?v=4" crossOrigin="use-credentials" /> <link rel="manifest" href="/site.webmanifest?v=4" crossOrigin="use-credentials" />
<link rel="mask-icon" href="safari-pinned-tab.svg?v=4" color="#1e9cd7" /> <link rel="mask-icon" href="/safari-pinned-tab.svg?v=4" color="#1e9cd7" />
</Head> </Head>
<body> <body>
<Main /> <Main />

@ -56,10 +56,10 @@ export async function getStaticProps() {
props: { props: {
initialSettings: settings, initialSettings: settings,
fallback: { fallback: {
"api/services": services, "/api/services": services,
"api/bookmarks": bookmarks, "/api/bookmarks": bookmarks,
"api/widgets": widgets, "/api/widgets": widgets,
"api/hash": false, "/api/hash": false,
}, },
...(await serverSideTranslations(settings.language ?? "en")), ...(await serverSideTranslations(settings.language ?? "en")),
}, },
@ -72,10 +72,10 @@ export async function getStaticProps() {
props: { props: {
initialSettings: {}, initialSettings: {},
fallback: { fallback: {
"api/services": [], "/api/services": [],
"api/bookmarks": [], "/api/bookmarks": [],
"api/widgets": [], "/api/widgets": [],
"api/hash": false, "/api/hash": false,
}, },
...(await serverSideTranslations("en")), ...(await serverSideTranslations("en")),
}, },
@ -86,8 +86,8 @@ export async function getStaticProps() {
function Index({ initialSettings, fallback }) { function Index({ initialSettings, fallback }) {
const windowFocused = useWindowFocus(); const windowFocused = useWindowFocus();
const [stale, setStale] = useState(false); const [stale, setStale] = useState(false);
const { data: errorsData } = useSWR("api/validate"); const { data: errorsData } = useSWR("/api/validate");
const { data: hashData, mutate: mutateHash } = useSWR("api/hash"); const { data: hashData, mutate: mutateHash } = useSWR("/api/hash");
useEffect(() => { useEffect(() => {
if (windowFocused) { if (windowFocused) {
@ -108,7 +108,7 @@ function Index({ initialSettings, fallback }) {
setStale(true); setStale(true);
localStorage.setItem("hash", hashData.hash); localStorage.setItem("hash", hashData.hash);
fetch("api/revalidate").then((res) => { fetch("/api/revalidate").then((res) => {
if (res.ok) { if (res.ok) {
window.location.reload(); window.location.reload();
} }
@ -179,9 +179,9 @@ function Home({ initialSettings }) {
setSettings(initialSettings); setSettings(initialSettings);
}, [initialSettings, setSettings]); }, [initialSettings, setSettings]);
const { data: services } = useSWR("api/services"); const { data: services } = useSWR("/api/services");
const { data: bookmarks } = useSWR("api/bookmarks"); const { data: bookmarks } = useSWR("/api/bookmarks");
const { data: widgets } = useSWR("api/widgets"); const { data: widgets } = useSWR("/api/widgets");
const servicesAndBookmarks = [ const servicesAndBookmarks = [
...services.map((sg) => sg.services).flat(), ...services.map((sg) => sg.services).flat(),
@ -368,17 +368,17 @@ function Home({ initialSettings }) {
</> </>
) : ( ) : (
<> <>
<link rel="apple-touch-icon" sizes="180x180" href="apple-touch-icon.png?v=4" /> <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png?v=4" />
<link rel="shortcut icon" href="homepage.ico" /> <link rel="shortcut icon" href="/homepage.ico" />
<link rel="icon" type="image/png" sizes="32x32" href="favicon-32x32.png?v=4" /> <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png?v=4" />
<link rel="icon" type="image/png" sizes="16x16" href="favicon-16x16.png?v=4" /> <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png?v=4" />
</> </>
)} )}
<meta name="msapplication-TileColor" content={themes[settings.color || "slate"][settings.theme || "dark"]} /> <meta name="msapplication-TileColor" content={themes[settings.color || "slate"][settings.theme || "dark"]} />
<meta name="theme-color" content={themes[settings.color || "slate"][settings.theme || "dark"]} /> <meta name="theme-color" content={themes[settings.color || "slate"][settings.theme || "dark"]} />
</Head> </Head>
<link rel="preload" href="api/config/custom.css" as="fetch" crossOrigin="anonymous" /> <link rel="preload" href="/api/config/custom.css" as="fetch" crossOrigin="anonymous" />
<style data-name="custom.css"> <style data-name="custom.css">
<FileContent <FileContent
path="custom.css" path="custom.css"
@ -387,7 +387,7 @@ function Home({ initialSettings }) {
emptyValue="/* No custom CSS */" emptyValue="/* No custom CSS */"
/> />
</style> </style>
<link rel="preload" href="api/config/custom.js" as="fetch" crossOrigin="anonymous" /> <link rel="preload" href="/api/config/custom.js" as="fetch" crossOrigin="anonymous" />
<script data-name="custom.js" src="/api/config/custom.js" async /> <script data-name="custom.js" src="/api/config/custom.js" async />
<div className="relative container m-auto flex flex-col justify-start z-10 h-full"> <div className="relative container m-auto flex flex-col justify-start z-10 h-full">

@ -23,7 +23,7 @@ export function formatProxyUrlWithSegments(widget, endpoint, segments) {
if (segments) { if (segments) {
params.append("segments", JSON.stringify(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) { export function formatProxyUrl(widget, endpoint, queryParams) {
@ -31,7 +31,7 @@ export function formatProxyUrl(widget, endpoint, queryParams) {
if (queryParams) { if (queryParams) {
params.append("query", JSON.stringify(queryParams)); params.append("query", JSON.stringify(queryParams));
} }
return `api/services/proxy?${params.toString()}`; return `/api/services/proxy?${params.toString()}`;
} }
export function asJson(data) { export function asJson(data) {

@ -12,10 +12,10 @@ export default function Component({ service }) {
const { widget } = service; const { widget } = service;
const { data: statusData, error: statusError } = useSWR( 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) { if (statsError || statsData?.error || statusError || statusData?.error) {
const finalError = statsError ?? statsData?.error ?? statusError ?? statusData?.error; const finalError = statsError ?? statsData?.error ?? statusError ?? statusData?.error;

Loading…
Cancel
Save