Skip to content

Commit

Permalink
Fix app UI and use redirect to handle non-root UI path
Browse files Browse the repository at this point in the history
  • Loading branch information
layerssss committed Jul 22, 2021
1 parent 2ffd6dc commit 5a53eb9
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1 +1 @@
PUBLIC_URL=/
PUBLIC_URL=./
10 changes: 4 additions & 6 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,10 @@ class Server {
);

this._uiServerExpress.use((request, response, next) => {
const acceptHeader = request.headers.accept || "";
if (acceptHeader.startsWith("text/html"))
return response.sendfile(
Path.join(__dirname, "../ui_build/index.html")
);
next();
response.writeHead(302, {
Location: `/?redirect=${request.url}`
});
response.end();
});

this._uiServer = Http.createServer();
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
"is-electron": "^2.1.0",
"nodemon": "^1.18.4",
"prettier": "^1.14.3",
"query-string": "^7.0.1",
"react": "^16.5.2",
"react-bootstrap": "^0.32.4",
"react-dom": "^16.5.2",
Expand Down
7 changes: 5 additions & 2 deletions src/localhostd_console.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
ButtonGroup,
ButtonToolbar
} from "react-bootstrap";
import QueryString from "query-string";

import ApplicationForm from "./application_form.js";
import ApplicationTerminal from "./application_terminal.js";
Expand Down Expand Up @@ -36,8 +37,10 @@ export default compose(
window.location.hostname.endsWith(`.${a.domain}`)
);

if (uiApplication && !uiApplication.locked && uiApplication.running)
window.location.reload();
if (uiApplication && !uiApplication.locked && uiApplication.running) {
const query = QueryString.parse(window.location.search);
window.location.href = query.redirect || "/";
}

const activeApplication =
uiApplication ||
Expand Down
25 changes: 25 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5829,6 +5829,11 @@ fill-range@^7.0.1:
dependencies:
to-regex-range "^5.0.1"

filter-obj@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/filter-obj/-/filter-obj-1.1.0.tgz#9b311112bc6c6127a16e016c6c5d7f19e0805c5b"
integrity sha1-mzERErxsYSehbgFsbF1/GeCAXFs=

finalhandler@~1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/finalhandler/-/finalhandler-1.1.2.tgz#b7e7d000ffd11938d0fdb053506f6ebabe9f587d"
Expand Down Expand Up @@ -10519,6 +10524,16 @@ query-string@^4.1.0:
object-assign "^4.1.0"
strict-uri-encode "^1.0.0"

query-string@^7.0.1:
version "7.0.1"
resolved "https://registry.yarnpkg.com/query-string/-/query-string-7.0.1.tgz#45bd149cf586aaa582dffc7ec7a8ad97dd02f75d"
integrity sha512-uIw3iRvHnk9to1blJCG3BTc+Ro56CBowJXKmNNAm3RulvPBzWLRqKSiiDk+IplJhsydwtuNMHi8UGQFcCLVfkA==
dependencies:
decode-uri-component "^0.2.0"
filter-obj "^1.1.0"
split-on-first "^1.0.0"
strict-uri-encode "^2.0.0"

querystring-es3@^0.2.0:
version "0.2.1"
resolved "https://registry.yarnpkg.com/querystring-es3/-/querystring-es3-0.2.1.tgz#9ec61f79049875707d69414596fd907a4d711e73"
Expand Down Expand Up @@ -11907,6 +11922,11 @@ speedometer@~0.1.2:
resolved "https://registry.yarnpkg.com/speedometer/-/speedometer-0.1.4.tgz#9876dbd2a169d3115402d48e6ea6329c8816a50d"
integrity sha1-mHbb0qFp0xFUAtSObqYynIgWpQ0=

split-on-first@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/split-on-first/-/split-on-first-1.1.0.tgz#f610afeee3b12bce1d0c30425e76398b78249a5f"
integrity sha512-43ZssAJaMusuKWL8sKUBQXHWOpq8d6CfN/u1p4gUzfJkM05C8rxTmYrkIPTXapZpORA6LkkzcUulJ8FqA7Uudw==

split-string@^3.0.1, split-string@^3.0.2:
version "3.1.0"
resolved "https://registry.yarnpkg.com/split-string/-/split-string-3.1.0.tgz#7cb09dda3a86585705c64b39a6466038682e8fe2"
Expand Down Expand Up @@ -12020,6 +12040,11 @@ strict-uri-encode@^1.0.0:
resolved "https://registry.yarnpkg.com/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz#279b225df1d582b1f54e65addd4352e18faa0713"
integrity sha1-J5siXfHVgrH1TmWt3UNS4Y+qBxM=

strict-uri-encode@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz#b9c7330c7042862f6b142dc274bbcc5866ce3546"
integrity sha1-ucczDHBChi9rFC3CdLvMWGbONUY=

string-length@^4.0.1:
version "4.0.2"
resolved "https://registry.yarnpkg.com/string-length/-/string-length-4.0.2.tgz#a8a8dc7bd5c1a82b9b3c8b87e125f66871b6e57a"
Expand Down

0 comments on commit 5a53eb9

Please sign in to comment.