diff --git a/README.md b/README.md index 1e3c2f7..bbddbdb 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,12 @@ Using this flag will tell GreenMail HTTP to add Access-Control-Allow-Origin to t -Duk.co.bigsoft.greenmail.ac_anywhere ``` +### Run the webinterface on a different port +By default, greenmail-http is accessible on port 7000. This can be changed by passing a different port to the following option: +``` +-Duk.co.bigsoft.greenmail.web_port=8000 +``` + ## Developers I'm always happy to receive push requests. Just a couple of guidelines for a speedy merge. diff --git a/src/main/java/uk/co/bigsoft/greenmail/Cfg.java b/src/main/java/uk/co/bigsoft/greenmail/Cfg.java index 2d521cb..f33fdc6 100644 --- a/src/main/java/uk/co/bigsoft/greenmail/Cfg.java +++ b/src/main/java/uk/co/bigsoft/greenmail/Cfg.java @@ -9,4 +9,8 @@ public boolean useTestData() { public boolean useAccessControlAnywhere() { return System.getProperty("uk.co.bigsoft.greenmail.ac_anywhere") != null; } + + public int getWebPort() { + return Integer.parseInt(System.getProperty("uk.co.bigsoft.greenmail.web_port", "7000")); + } } diff --git a/src/main/java/uk/co/bigsoft/greenmail/Main.java b/src/main/java/uk/co/bigsoft/greenmail/Main.java index 0a71410..c7df7af 100644 --- a/src/main/java/uk/co/bigsoft/greenmail/Main.java +++ b/src/main/java/uk/co/bigsoft/greenmail/Main.java @@ -52,7 +52,7 @@ private static void populate(GreenMail gm) { } private static void startHttpServer(GreenMail greenMail) { - Javalin app = Javalin.create().start(7000); + Javalin app = Javalin.create().start(cfg.getWebPort()); app.config.addStaticFiles("/frontend", Location.CLASSPATH); app.get("/imap/:email/inbox", new ImapGetInBoxCommand(greenMail)); app.get("/imap/:email", new ImapListMailBoxCommand(greenMail)); diff --git a/src/main/web/package.json b/src/main/web/package.json index b88e28e..d8c2c37 100644 --- a/src/main/web/package.json +++ b/src/main/web/package.json @@ -25,6 +25,7 @@ "test": "react-scripts test", "eject": "react-scripts eject" }, + "proxy": "http://localhost:7000", "eslintConfig": { "extends": "react-app" }, diff --git a/src/main/web/src/c/GmhUrl.js b/src/main/web/src/c/GmhUrl.js index 0bf4819..f2e1888 100644 --- a/src/main/web/src/c/GmhUrl.js +++ b/src/main/web/src/c/GmhUrl.js @@ -1,5 +1,5 @@ -let base = 'http://localhost:7000' +let base = window.location.origin; let mappings = { //SERVER_CONFIG: '/', ALL_IMAP: '/imap',