Skip to content

Commit

Permalink
fix: use inbuilt frontend dev server to proxy API
Browse files Browse the repository at this point in the history
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_`.
  • Loading branch information
vividvilla committed Oct 2, 2020
1 parent 23d479e commit 6c234f1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions frontend/.env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
LISTMONK_FRONTEND_PORT=8080
LISTMONK_API_URL="http://127.0.0.1:9000"
9 changes: 9 additions & 0 deletions frontend/vue.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
};

0 comments on commit 6c234f1

Please sign in to comment.