summaryrefslogtreecommitdiff
path: root/frontend/src/api/socket.js
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2020-07-15 15:45:02 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2020-08-24 19:48:05 +0200
commita196ba2c08bd16479134ab542f2560b75f19424f (patch)
treec44ad8d0c89c8997068e7c792265bd1db43c347c /frontend/src/api/socket.js
parent02997b2522b9c66072b16f1425c02e81e0085e3c (diff)
Make frontend independent of API
This change makes the frontend independent of the API by removing the static file serving logic from the API server. Instead, we can serve the frontend as static HTML over CDNs.
Diffstat (limited to 'frontend/src/api/socket.js')
-rw-r--r--frontend/src/api/socket.js8
1 files changed, 3 insertions, 5 deletions
diff --git a/frontend/src/api/socket.js b/frontend/src/api/socket.js
index 93ce8fa8..759c119e 100644
--- a/frontend/src/api/socket.js
+++ b/frontend/src/api/socket.js
@@ -6,11 +6,9 @@ let requestIdCounter = 0
const callbacks = {}
export function setupSocketConnection(onConnect) {
- let port = window.location.port
- if (process.env.NODE_ENV !== 'production') {
- port = 8081
- }
- socket = io.connect(window.location.protocol + '//' + window.location.hostname + ':' + port)
+ const apiUrl = process.env.REACT_APP_API_URL || window.location.hostname + ':' + window.location.port;
+
+ socket = io.connect(window.location.protocol + '//' + apiUrl);
socket.on('connect', onConnect)
socket.on('response', onSocketResponse)
}