From 6c234f1b1d94d3aa3f0ff197f46f344fb5853431 Mon Sep 17 00:00:00 2001 From: Vivek R Date: Sat, 3 Oct 2020 04:28:50 +0530 Subject: [PATCH] fix: use inbuilt frontend dev server to proxy API Vue's inbuilt dev server can be configured to proxy API for development instead of directing developers to setup Nginx proxy. Additionally this commit also adds an option to configure frontend port on which dev server runs. Sample env config file is under `frontend/.env.sample`, it can be copied to either `frontend/.env` or `frontend/.env.local`. Available options are LISTMONK_FRONTEND_PORT - Configure frontend dev server port (defaults to 8080) LISTMONK_API_URL - Configure API server URL (defaults to http://127.0.0.1:9000) Since env variables are sourced to current session we are prefixing it with `LISTMONK_`. --- frontend/.env.sample | 2 ++ frontend/vue.config.js | 9 +++++++++ 2 files changed, 11 insertions(+) create mode 100644 frontend/.env.sample diff --git a/frontend/.env.sample b/frontend/.env.sample new file mode 100644 index 0000000..367c37a --- /dev/null +++ b/frontend/.env.sample @@ -0,0 +1,2 @@ +LISTMONK_FRONTEND_PORT=8080 +LISTMONK_API_URL="http://127.0.0.1:9000" diff --git a/frontend/vue.config.js b/frontend/vue.config.js index a339bb9..3a517bb 100644 --- a/frontend/vue.config.js +++ b/frontend/vue.config.js @@ -14,4 +14,13 @@ module.exports = { productionSourceMap: false, filenameHashing: true, + + devServer: { + port: process.env.LISTMONK_FRONTEND_PORT || 8080, + proxy: { + "^/api": { + target: process.env.LISTMONK_API_URL || "http://127.0.0.1:9000" + } + } + } };