From 6526b514296306987ccd0d9ca33701c609c9e804 Mon Sep 17 00:00:00 2001 From: Dunemask Date: Tue, 12 Jul 2022 23:28:47 +0000 Subject: [PATCH] Prepared for serving --- lib/routes/react-route.js | 8 +++++--- lib/routes/router.js | 2 +- src/views/Navbar.jsx | 13 +++++++------ src/views/NotFound.jsx | 3 +++ src/views/Views.jsx | 26 +++++++++++++++++++------- vite.config.js | 4 ++++ 6 files changed, 39 insertions(+), 17 deletions(-) create mode 100644 src/views/NotFound.jsx diff --git a/lib/routes/react-route.js b/lib/routes/react-route.js index 1a43041..9438566 100644 --- a/lib/routes/react-route.js +++ b/lib/routes/react-route.js @@ -1,6 +1,8 @@ import express, { Router } from "express"; - +import path from "path"; const router = Router(); - -router.use("/qualiteer", express.static("build/")); +router.use("/", express.static(path.resolve("./build"))); +router.get("/*", (req, res) => + res.sendFile(path.resolve("./build/index.html")) +); export default router; diff --git a/lib/routes/router.js b/lib/routes/router.js index b617eb6..6da48fb 100644 --- a/lib/routes/router.js +++ b/lib/routes/router.js @@ -19,7 +19,7 @@ export default function buildRoutes(pg, skio) { // Middlewares // Routes - router.use(react); // Static Build Route + router.use("/qualiteer", react); // Static Build Route router.use("/api/results", results); router.use("/api/alerting", alerting); router.use("/api/catalog", catalog); diff --git a/src/views/Navbar.jsx b/src/views/Navbar.jsx index 6d3037d..cd7abd9 100644 --- a/src/views/Navbar.jsx +++ b/src/views/Navbar.jsx @@ -61,9 +61,10 @@ export default function Navbar(props) { })); const navHeader = () => { - const pathStr = - location.pathname.charAt(1).toUpperCase() + location.pathname.slice(2); - if (location.pathname !== "/failing") return pathStr; + const name = location.pathname.split("/").pop(); + + const pathStr = name.charAt(0).toUpperCase() + name.slice(1); + if (location.pathname !== "/qualiteer/failing") return pathStr; return ( {icons[index]} @@ -126,7 +127,7 @@ export default function Navbar(props) { diff --git a/src/views/NotFound.jsx b/src/views/NotFound.jsx new file mode 100644 index 0000000..b3bb728 --- /dev/null +++ b/src/views/NotFound.jsx @@ -0,0 +1,3 @@ +export default function NotFound() { + return

Error 404 not found!

; +} diff --git a/src/views/Views.jsx b/src/views/Views.jsx index 9074c0d..0e2ac7d 100644 --- a/src/views/Views.jsx +++ b/src/views/Views.jsx @@ -11,6 +11,7 @@ import Jobs from "./jobs/Jobs.jsx"; import Catalog from "./catalog/Catalog.jsx"; import Settings from "./settings/Settings.jsx"; import About from "./about/About.jsx"; +import NotFound from "./NotFound.jsx"; export default function Views() { return ( @@ -20,13 +21,24 @@ export default function Views() { - } /> - } /> - } /> - } /> - } /> - } /> - } /> + } + /> + } + /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> diff --git a/vite.config.js b/vite.config.js index 967e159..904b0fb 100644 --- a/vite.config.js +++ b/vite.config.js @@ -10,5 +10,9 @@ export default () => { port: 443, }, }, + build: { + outDir: "./build", + }, + base: "/qualiteer/", }); };