From 2fc4db34e95792ede16645198595a90c50c9ef2b Mon Sep 17 00:00:00 2001 From: Marks Polakovs Date: Tue, 7 Apr 2020 11:37:14 +0200 Subject: [PATCH] client: split URLS out into env vars --- .env | 5 ++++- .env.prod | 4 ++++ Jenkinsfile | 1 + src/api.ts | 5 ++--- src/broadcast/rtc_streamer.ts | 2 +- 5 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 .env.prod diff --git a/.env b/.env index 993341b..98a640a 100644 --- a/.env +++ b/.env @@ -1,2 +1,5 @@ HOST=local-development.ury.org.uk -REACT_APP_VERSION=$npm_package_version \ No newline at end of file +REACT_APP_VERSION=$npm_package_version +REACT_APP_MYRADIO_NONAPI_BASE=https://ury.org.uk/myradio-staging +REACT_APP_MYRADIO_BASE=https://ury.org.uk/api-staging/v2 +REACT_APP_WS_URL=wss://audio.ury.org.uk/webstudio/stream \ No newline at end of file diff --git a/.env.prod b/.env.prod new file mode 100644 index 0000000..50c6e4a --- /dev/null +++ b/.env.prod @@ -0,0 +1,4 @@ +REACT_APP_VERSION=$npm_package_version +REACT_APP_MYRADIO_NONAPI_BASE=https://ury.org.uk/myradio +REACT_APP_MYRADIO_BASE=https://ury.org.uk/api/v2 +REACT_APP_WS_URL=wss://audio.ury.org.uk/webstudio/stream \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile index c7cbe7d..a69fa76 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -30,6 +30,7 @@ pipeline { environment { REACT_APP_MYRADIO_NONAPI_BASE = 'https://ury.org.uk/myradio' REACT_APP_MYRADIO_BASE = 'https://ury.org.uk/api/v2' + REACT_APP_WS_URL = 'wss://audio.ury.org.uk/webstudio/stream' } steps { sh 'sed -i -e \'s/ury.org.uk\\/webstudio-dev/ury.org.uk\\/webstudio/\' package.json' diff --git a/src/api.ts b/src/api.ts index a3b45cc..eb8b442 100644 --- a/src/api.ts +++ b/src/api.ts @@ -1,10 +1,9 @@ import qs from "qs"; export const MYRADIO_NON_API_BASE = - process.env.REACT_APP_MYRADIO_NONAPI_BASE || - "https://ury.org.uk/myradio-staging"; + process.env.REACT_APP_MYRADIO_NONAPI_BASE!; export const MYRADIO_BASE_URL = - process.env.REACT_APP_MYRADIO_BASE || "https://ury.org.uk/api-staging/v2"; + process.env.REACT_APP_MYRADIO_BASE!; const MYRADIO_API_KEY = process.env.REACT_APP_MYRADIO_KEY!; class ApiException extends Error {} diff --git a/src/broadcast/rtc_streamer.ts b/src/broadcast/rtc_streamer.ts index d001e45..9793fd2 100644 --- a/src/broadcast/rtc_streamer.ts +++ b/src/broadcast/rtc_streamer.ts @@ -42,7 +42,7 @@ export class WebRTCStreamer extends Streamer { } async start(): Promise { - this.ws = new WebSocket("ws://audio.ury.org.uk/webstudio/stream"); + this.ws = new WebSocket(process.env.REACT_APP_WS_URL!); this.ws.onopen = e => { console.log("WS open"); this.onStateChange(this.mapStateToConnectionState());