codyseibert / tab-tracker

A Vue.js / Express.js web application for keeping track of guitar tabs
MIT License
520 stars 197 forks source link

connecting server and client #24

Open firezdog opened 6 years ago

firezdog commented 6 years ago

The way that app is currently set up, it seems like the client needs to know what port the server is running on in order to access the API. Is there any way to set up an interface between server and client that will help the client to determine the port the server is running on? I was thinking about some kind of proxy running from the server that would give the client a fixed end-point that is guaranteed to work no matter what environment the server is running on...

As a kind of stop-gap measure I imported the server config into the client's api.js:

import serverConfig from '../../../server/src/config/config'

from which I am then able to access the port -- but this seems extremely insecure. I was hoping there was some standard way of solving this problem. (On my mac, the port for the server is set to 8083; on my Ubuntu PC it's set to 8081. In general there isn't some way to guarantee that a port gets set to a certain value in every environment, because different environments might already be using that port.)