From 83aeb08cafd114b6c2e509e16174d11d0ba062aa Mon Sep 17 00:00:00 2001 From: Hironsan Date: Fri, 27 Nov 2020 17:57:51 +0900 Subject: [PATCH] Enable to login on remote machine, fix #836 --- docker-compose.dev.yml | 2 ++ docker-compose.prod.yml | 2 ++ frontend/nuxt.config.js | 10 +++++++++- frontend/package.json | 1 + frontend/yarn.lock | 8 ++++++++ 5 files changed, 22 insertions(+), 1 deletion(-) diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index d28d03dc..34bb7eac 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -25,6 +25,8 @@ services: frontend: image: node:13.7.0 command: ["/src/frontend/dev-nuxt.sh"] + environment: + API_URL: "http://backend:8000" volumes: - .:/src - node_modules:/src/frontend/node_modules diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index d4a3e5bb..803ed28c 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -21,6 +21,8 @@ services: frontend: build: ./frontend + environment: + API_URL: "http://backend:8000" volumes: - www:/app/dist environment: diff --git a/frontend/nuxt.config.js b/frontend/nuxt.config.js index 6d5c4c89..348405e8 100644 --- a/frontend/nuxt.config.js +++ b/frontend/nuxt.config.js @@ -32,7 +32,7 @@ export default { }, env: { - baseUrl: process.env.NODE_ENV === 'production' ? '/v1' : 'http://127.0.0.1:8000/v1' + baseUrl: '/v1' }, /* @@ -73,6 +73,14 @@ export default { ** See https://axios.nuxtjs.org/options */ axios: { + proxy: true + }, + + proxy: { + // Use a fake value for use at build-time + '/v1/': { + target: process.env.API_URL || 'http://127.0.0.1:12345' + } }, /* ** vuetify module configuration diff --git a/frontend/package.json b/frontend/package.json index 7285badf..960003c6 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -16,6 +16,7 @@ }, "dependencies": { "@nuxtjs/axios": "^5.12.0", + "@nuxtjs/proxy": "^2.0.1", "@nuxtjs/vuetify": "^1.11.2", "@toast-ui/vue-editor": "^1.1.1", "chart.js": "^2.9.3", diff --git a/frontend/yarn.lock b/frontend/yarn.lock index d68e26f2..6fefd772 100644 --- a/frontend/yarn.lock +++ b/frontend/yarn.lock @@ -1542,6 +1542,14 @@ consola "^2.11.3" http-proxy-middleware "^1.0.4" +"@nuxtjs/proxy@^2.0.1": + version "2.0.1" + resolved "https://registry.yarnpkg.com/@nuxtjs/proxy/-/proxy-2.0.1.tgz#2469b6e316311aa8c60d348502a54bfe6d5536aa" + integrity sha512-RVZ6iYeAuWteot9oer3vTDCOEiTwg37Mqf6yy8vPD0QQaw4z3ykgM++MzfUl85jM14+qNnODZj5EATRoCY009Q== + dependencies: + consola "^2.11.3" + http-proxy-middleware "^1.0.4" + "@nuxtjs/vuetify@^1.11.2": version "1.11.2" resolved "https://registry.yarnpkg.com/@nuxtjs/vuetify/-/vuetify-1.11.2.tgz#fefa861d98c021e10dd579a5b91b34b3fb49dc99"