From d18abaf0678c7e84cd23d98ed63676f0cf219cc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Thu, 25 Jun 2020 10:32:47 +0200 Subject: [PATCH] Enabling optional https in development --- .github/workflows/continuous_integration.yml | 2 +- deeployer.libsonnet | 2 +- docker-compose.yaml | 26 ++++++++++++++++++-- front/src/Enum/EnvironmentVariable.ts | 2 +- 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml index a326bb1b..7c74fb66 100644 --- a/.github/workflows/continuous_integration.yml +++ b/.github/workflows/continuous_integration.yml @@ -29,7 +29,7 @@ jobs: - name: "Build" run: yarn run build env: - API_URL: "http://localhost:8080" + API_URL: "localhost:8080" working-directory: "front" - name: "Lint" diff --git a/deeployer.libsonnet b/deeployer.libsonnet index 975686be..69bc8fcf 100644 --- a/deeployer.libsonnet +++ b/deeployer.libsonnet @@ -24,7 +24,7 @@ }, "ports": [80], "env": { - "API_URL": "https://api."+url + "API_URL": "api."+url } }, "website": { diff --git a/docker-compose.yaml b/docker-compose.yaml index b2093f0c..85027a3d 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -2,9 +2,14 @@ version: "3" services: reverse-proxy: image: traefik:v2.0 - command: --api.insecure=true --providers.docker + command: + - --api.insecure=true + - --providers.docker + - --entryPoints.web.address=:80 + - --entryPoints.websecure.address=:443 ports: - "80:80" + - "443:443" # The Web UI (enabled by --api.insecure=true) - "8080:8080" depends_on: @@ -19,14 +24,20 @@ services: DEBUG_MODE: "$DEBUG_MODE" HOST: "0.0.0.0" NODE_ENV: development - API_URL: http://api.workadventure.localhost + API_URL: api.workadventure.localhost STARTUP_COMMAND_1: yarn install command: yarn run start volumes: - ./front:/usr/src/app labels: - "traefik.http.routers.front.rule=Host(`play.workadventure.localhost`)" + - "traefik.http.routers.front.entryPoints=web" - "traefik.http.services.front.loadbalancer.server.port=8080" + - "traefik.http.routers.front-ssl.rule=Host(`play.workadventure.localhost`)" + - "traefik.http.routers.front-ssl.entryPoints=websecure" + - "traefik.http.routers.front-ssl.tls=true" + - "traefik.http.routers.front-ssl.service=front" + back: image: thecodingmachine/nodejs:12 @@ -39,7 +50,13 @@ services: - ./back:/usr/src/app labels: - "traefik.http.routers.back.rule=Host(`api.workadventure.localhost`)" + - "traefik.http.routers.back.entryPoints=web" - "traefik.http.services.back.loadbalancer.server.port=8080" + - "traefik.http.routers.back-ssl.rule=Host(`api.workadventure.localhost`)" + - "traefik.http.routers.back-ssl.entryPoints=websecure" + - "traefik.http.routers.back-ssl.tls=true" + - "traefik.http.routers.back-ssl.service=back" + website: image: thecodingmachine/nodejs:12-apache @@ -51,4 +68,9 @@ services: - ./website:/var/www/html labels: - "traefik.http.routers.website.rule=Host(`workadventure.localhost`)" + - "traefik.http.routers.website.entryPoints=web" - "traefik.http.services.website.loadbalancer.server.port=80" + - "traefik.http.routers.website-ssl.rule=Host(`workadventure.localhost`)" + - "traefik.http.routers.website-ssl.entryPoints=websecure" + - "traefik.http.routers.website-ssl.tls=true" + - "traefik.http.routers.website-ssl.service=website" diff --git a/front/src/Enum/EnvironmentVariable.ts b/front/src/Enum/EnvironmentVariable.ts index 6e0edd8f..c1f9efe4 100644 --- a/front/src/Enum/EnvironmentVariable.ts +++ b/front/src/Enum/EnvironmentVariable.ts @@ -1,5 +1,5 @@ const DEBUG_MODE: boolean = process.env.DEBUG_MODE == "true"; -const API_URL = process.env.API_URL || "http://api.workadventure.localhost"; +const API_URL = window.location.protocol + '//' + process.env.API_URL || "http://api.workadventure.localhost"; const RESOLUTION = 3; const ZOOM_LEVEL = 1/*3/4*/; const POSITION_DELAY = 200; // Wait 200ms between sending position events