Skip to content

Commit 9130557

Browse files
authored
Set the dev server API proxy target with an env variable (openhab#222)
Signed-off-by: Yannick Schaus <[email protected]>
1 parent a06c766 commit 9130557

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

bundles/org.openhab.ui/CONTRIBUTING.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,10 @@ You need Node 8.10.0 or later and npm 5.6.0. Change to the `web` directory, gath
2424

2525
Before starting the development server with `npm start`, you should have an instance of openHAB (either a complete distribution or the demo app) running on _localhost:8080_.
2626
The development server will run on the next available port (for instance, 8081) and proxy requests to well-known openHAB URLs like the REST API or icon servlet, forwarding them to their equivalent on port 8080.
27-
If you wish to change the target of these forwards, allowing to target a remote instance, look for `const apiBaseUrl` in `build/webpack.config.js` and change it accordingly before starting the server.
28-
Don't commit changes to the base URL to avoid confusing others!
27+
If you wish to change the target of these forwards and use a remote instance, set the `OH_APIBASE` environment variable to the desired URL (e.g. `OH_APIBASE=http://openhab-dev:8080`) before running `npm start`.
2928

3029
You can also run the unit tests (`test/jest`) and e2e (`test/cypress`) tests using the abovementioned commands.
31-
Cypress is configured to assume the development server is running on port 8081 - you can change that in `cypress.json` but again, remember not to commit.
30+
Cypress is configured to assume the development server is running on port 8081 - you can change that in `cypress.json` but remember not to commit.
3231
You can also use Majestic GUI to run the unit tests and temporarily collect code coverage and view coverage reports (it is disabled by default for performance reasons): install it globally with `npm install -g majestic`, and run `majestic` in the root web folder to open Majestic in a browser window.
3332

3433
## PWA

bundles/org.openhab.ui/web/build/webpack.config.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ const target = process.env.TARGET || 'web'
1919
const buildSourceMaps = process.env.SOURCE_MAPS || false
2020
const isCordova = target === 'cordova'
2121

22-
// const apiBaseUrl = 'http://openhab:8080' // 'http://demo.openhab.org:8080' // 'http://localhost:8080'
23-
const apiBaseUrl = 'http://localhost:8080'
22+
const apiBaseUrl = process.env.OH_APIBASE || 'http://localhost:8080'
2423

2524
module.exports = {
2625
mode: env,

0 commit comments

Comments
 (0)