Skip to content

Commit c1d85cf

Browse files
committed
add hostname detection and fix status on miss
1 parent e21c118 commit c1d85cf

File tree

4 files changed

+41
-21
lines changed

4 files changed

+41
-21
lines changed

client/src/App.tsx

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { Provider } from './components/ui/provider';
2+
import { BrowserRouter, Route, Routes } from 'react-router-dom';
3+
import Loading from './pages/Loading';
4+
import { lazy, Suspense } from 'react';
5+
6+
const Home = lazy(() => import('./pages/Home'));
7+
const StatusPage = lazy(() => import('./pages/StatusPage'));
8+
const Error = lazy(() => import('./pages/Error'));
9+
10+
const App = () => {
11+
const hostname = window.location.hostname;
12+
13+
return (
14+
<Provider>
15+
<Suspense fallback={<Loading />}>
16+
<BrowserRouter future={{ v7_startTransition: true, v7_relativeSplatPath: true }}>
17+
<Routes>
18+
{hostname === "status.jomity.net" ? (
19+
<>
20+
<Route path="/" element={<StatusPage />} />
21+
<Route path="*" element={<Error />} />
22+
</>
23+
) : (
24+
<>
25+
<Route path="/" element={<Home />} />
26+
<Route path="/status" element={<StatusPage />} />
27+
<Route path="*" element={<Error />} />
28+
</>
29+
)}
30+
</Routes>
31+
</BrowserRouter>
32+
</Suspense>
33+
</Provider>
34+
)
35+
}
36+
37+
export default App;

client/src/index.tsx

+3-19
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
1-
import { Provider } from './components/ui/provider';
2-
import { lazy, StrictMode, Suspense } from 'react';
1+
import { lazy, StrictMode } from 'react';
32
import { createRoot } from 'react-dom/client';
4-
import { BrowserRouter, Route, Routes } from 'react-router-dom';
5-
import Loading from './pages/Loading';
63
import './index.css';
74
import favicon from './images/favicon.ico';
8-
9-
const Home = lazy(() => import('./pages/Home'));
10-
const StatusPage = lazy(() => import('./pages/StatusPage'));
11-
const Error = lazy(() => import('./pages/Error'));
5+
import App from './App';
126

137
const link = document.createElement('link');
148
link.rel = 'icon';
@@ -17,16 +11,6 @@ document.head.appendChild(link);
1711

1812
createRoot(document.querySelector('#entry')!).render(
1913
<StrictMode>
20-
<Provider>
21-
<Suspense fallback={<Loading />}>
22-
<BrowserRouter future={{ v7_startTransition: true, v7_relativeSplatPath: true }}>
23-
<Routes>
24-
<Route path="/" element={<Home />} />
25-
<Route path="/status" element={<StatusPage />} />
26-
<Route path="*" element={<Error />} />
27-
</Routes>
28-
</BrowserRouter>
29-
</Suspense>
30-
</Provider>
14+
<App />
3115
</StrictMode>
3216
)

client/src/pages/StatusPage.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ const StatusPage = () => {
107107
const process = processes.find((r) => r.name === p.key);
108108

109109
if (!process) {
110-
p.status = "unknown";
110+
p.status = "disabled";
111111
return p;
112112
}
113113

server/src/WebServer.ts

-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ export class WebServer {
131131

132132
if (err || !stats.isFile()) {
133133
serveFile(res, join(this.root, "index.html"), "text/html");
134-
return;
135134
} else {
136135
serveFile(res, filePath, getContentType(url), encoding);
137136
}

0 commit comments

Comments
 (0)