From 7d4e24cb5cb3c605f24bf386f6458255921ea4e3 Mon Sep 17 00:00:00 2001 From: Oliver Boehlk Date: Sat, 18 Apr 2020 18:13:52 +0200 Subject: [PATCH 1/2] make all test work again locally --- backend/index.js | 2 ++ frontend/src/components/resourcechart/resourcechart.js | 1 - frontend/src/components/selectResource/index.js | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/backend/index.js b/backend/index.js index b9e6872..8b1707d 100644 --- a/backend/index.js +++ b/backend/index.js @@ -34,6 +34,8 @@ app.use(express.static(path.join(__dirname, 'frontend'))); app.use(express.static(`${__dirname}/./frontend`)); app.all("/*", function (req, res, next) { + if (/^\/simcompanies\/API\/.*/.test(req.url)) + req.url = req.url.substring(13); if (!/^\/API\/.*/.test(req.url)) { return res.sendFile(path.join(__dirname, 'frontend', 'index.html')); } else return next(); diff --git a/frontend/src/components/resourcechart/resourcechart.js b/frontend/src/components/resourcechart/resourcechart.js index 4f91bd9..66e9d22 100644 --- a/frontend/src/components/resourcechart/resourcechart.js +++ b/frontend/src/components/resourcechart/resourcechart.js @@ -11,7 +11,6 @@ export default function ResourceChart(props) { const [data, setData] = React.useState(null); let { id } = useParams(); const loadData = async () => { - console.log(id) let nextData = await fetch(`/simcompanies/API/day?date=${props["day"]}&kind=${id}`); nextData = await nextData.json(); for (let i = 0; i < nextData.length; i++) { diff --git a/frontend/src/components/selectResource/index.js b/frontend/src/components/selectResource/index.js index 3912918..269876a 100644 --- a/frontend/src/components/selectResource/index.js +++ b/frontend/src/components/selectResource/index.js @@ -39,7 +39,7 @@ export default function SelectResource() { const [resources, setResources] = React.useState(null); const loadResources = async () => { - var resourceJSON = await fetch("API/resourcelist"); + var resourceJSON = await fetch("/simcompanies/API/resourcelist"); resourceJSON = await resourceJSON.json(); let rArr = []; for (let i = 0; i < resourceJSON.length; i++) { From 8858d4ae7a95c91a126060087086fbce47abadec Mon Sep 17 00:00:00 2001 From: Oliver Boehlk Date: Sat, 18 Apr 2020 18:48:17 +0200 Subject: [PATCH 2/2] use nodemon only in debug mode --- backend/package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/backend/package.json b/backend/package.json index 1c95193..55df2d5 100644 --- a/backend/package.json +++ b/backend/package.json @@ -4,7 +4,8 @@ "description": "The backend for the Sim Companies dashboard providing prices from the database", "main": "index.js", "scripts": { - "start": "nodemon index.js", + "start": "node index.js", + "debug": "nodemon index.js", "test": "echo \"Error: no test specified\" && exit 1" }, "author": "Oliver Boehlk", @@ -16,4 +17,4 @@ "node-fetch": "^2.6.0", "nodemon": "^2.0.2" } -} +} \ No newline at end of file