summaryrefslogtreecommitdiff
path: root/frontend
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2020-10-27 23:08:12 +0100
committerFabian Mastenbroek <mail.fabianm@gmail.com>2020-10-27 23:08:12 +0100
commit45c3adb6fdfed5c191d8a14562eaabbd54c5c91b (patch)
tree739308156e6c92e900a94e69c8acaf0b612640fb /frontend
parent70026cebc0fd20b660cafe0bf95d0eea73459de2 (diff)
Split prod and dev config for Docker Compose
This change splits the Docker Compose configuration into three files in order to share the configuration for different environments (e.g. development and production). Furthermore, this change drops the requirement for a reverse proxy.
Diffstat (limited to 'frontend')
-rw-r--r--frontend/.dockerignore1
-rw-r--r--frontend/nginx.conf17
-rw-r--r--frontend/src/api/routes/token-signin.js10
-rw-r--r--frontend/src/api/socket.js6
4 files changed, 10 insertions, 24 deletions
diff --git a/frontend/.dockerignore b/frontend/.dockerignore
new file mode 100644
index 00000000..3c3629e6
--- /dev/null
+++ b/frontend/.dockerignore
@@ -0,0 +1 @@
+node_modules
diff --git a/frontend/nginx.conf b/frontend/nginx.conf
index ed7e5cfe..1b4e3a73 100644
--- a/frontend/nginx.conf
+++ b/frontend/nginx.conf
@@ -8,23 +8,6 @@ server {
try_files $uri $uri/ /index.html;
}
- location /socket.io {
- proxy_http_version 1.1;
-
- proxy_buffering off;
- proxy_set_header Upgrade $http_upgrade;
- proxy_set_header Connection "Upgrade";
- proxy_pass http://api:8081/socket.io;
- }
-
- location /tokensignin {
- proxy_pass http://api:8081/tokensignin;
- }
-
- location /api {
- proxy_pass http://api:8081/api;
- }
-
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
diff --git a/frontend/src/api/routes/token-signin.js b/frontend/src/api/routes/token-signin.js
index 577f4723..d6cff570 100644
--- a/frontend/src/api/routes/token-signin.js
+++ b/frontend/src/api/routes/token-signin.js
@@ -1,10 +1,10 @@
export function performTokenSignIn(token) {
const apiUrl = process.env.REACT_APP_API_BASE_URL || ''
- const data = new FormData()
- data.append('idtoken', token)
- return fetch(`https://${apiUrl}/tokensignin`, {
+ return fetch(`${apiUrl}/tokensignin`, {
method: 'POST',
- body: data,
- })
+ body: new URLSearchParams({
+ idtoken: token,
+ }),
+ }).then((res) => res.json())
}
diff --git a/frontend/src/api/socket.js b/frontend/src/api/socket.js
index 6974d5eb..1c432167 100644
--- a/frontend/src/api/socket.js
+++ b/frontend/src/api/socket.js
@@ -6,9 +6,11 @@ let requestIdCounter = 0
const callbacks = {}
export function setupSocketConnection(onConnect) {
- const apiUrl = process.env.REACT_APP_API_BASE_URL || window.location.hostname + ':' + window.location.port
+ const apiUrl =
+ process.env.REACT_APP_API_BASE_URL ||
+ `${window.location.protocol}//${window.location.hostname}:${window.location.port}`
- socket = io.connect(window.location.protocol + '//' + apiUrl)
+ socket = io.connect(apiUrl)
socket.on('connect', onConnect)
socket.on('response', onSocketResponse)
}