From fc58c659c6f9429b8f9d331dbb60ce6daec767ed Mon Sep 17 00:00:00 2001 From: aleph-naught2tog Date: Sat, 5 Jan 2019 16:01:02 -0600 Subject: [PATCH] Ensures root loads index.html --- package-lock.json | 13 +++++++++++++ server/index.doc.js | 7 ++++++- server/index.js | 6 +++++- 3 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 package-lock.json diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..a2e572c --- /dev/null +++ b/package-lock.json @@ -0,0 +1,13 @@ +{ + "name": "ts_without_dependencies", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "typescript": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.2.2.tgz", + "integrity": "sha512-VCj5UiSyHBjwfYacmDuc/NOk4QQixbE+Wn7MFJuS0nRuPQbof132Pw4u53dm264O8LPc2MVsc7RJNml5szurkg==" + } + } +} diff --git a/server/index.doc.js b/server/index.doc.js index eba578f..f2939eb 100644 --- a/server/index.doc.js +++ b/server/index.doc.js @@ -104,7 +104,12 @@ const getPath = request => { if (isModuleRequest(request)) { return `${SERVER_ROOT_FOLDER}${parsedUrl.pathname}.js`; } else { - return `${SERVER_ROOT_FOLDER}${parsedUrl.pathname}`; + // This ensures that navigating to "localhost:PORT" just loades the homepage + if (parsedUrl.pathname === '/') { + return `${SERVER_ROOT_FOLDER}${parsedUrl.pathname}index.html`; + } else { + return `${SERVER_ROOT_FOLDER}${parsedUrl.pathname}`; + } } }; diff --git a/server/index.js b/server/index.js index d9bcbbc..72560c8 100644 --- a/server/index.js +++ b/server/index.js @@ -37,7 +37,11 @@ const getPath = request => { if (isModuleRequest(request)) { return `${SERVER_ROOT_FOLDER}${parsedUrl.pathname}.js`; } else { - return `${SERVER_ROOT_FOLDER}${parsedUrl.pathname}`; + if (parsedUrl.pathname === '/') { + return `${SERVER_ROOT_FOLDER}${parsedUrl.pathname}index.html`; + } else { + return `${SERVER_ROOT_FOLDER}${parsedUrl.pathname}`; + } } };