client: split URLS out into env vars

This commit is contained in:
Marks Polakovs 2020-04-07 11:37:14 +02:00
parent bdf043203f
commit 2fc4db34e9
5 changed files with 12 additions and 5 deletions

3
.env
View file

@ -1,2 +1,5 @@
HOST=local-development.ury.org.uk
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

4
.env.prod Normal file
View file

@ -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

1
Jenkinsfile vendored
View file

@ -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'

View file

@ -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 {}

View file

@ -42,7 +42,7 @@ export class WebRTCStreamer extends Streamer {
}
async start(): Promise<void> {
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());