Open G-Ambatte opened 2 years ago
A slightly better approach may be along the lines of:
const localEnvironments = ['local','docker','other'];
if(localEnvironments.includes(process.env.NODE_ENV) {
[...]
}
This allows the same static directory logic to be applied to other environments than just local
, as deemed appropriate, and is easily extended to any additional NODE_ENV settings that might be developed in the future.
It also might be appropriate to store the content of localEnvironments
in a config file.
By modifying
server.js
slightly, we can allow users with local installs to serve images from their local directory, meaning that they will no long need to rely on services outside of their local machine (e.g. Imgur.com).Steps:
Create a directory "staticImages" in the project root directory.
Add the following lines to
server.js
:Restart the Homebrewery server.
As you will see in the following screenshot, my Ubuntu local install can now access images hosted in the
staticImages
folder.EDIT: In the above image, my specific configuration is visible - I have symlinked
/home/hb-test/images
to/usr/local/homebrewery/staticImages
, which is why two different paths are shown - I can upload files via WinSCP to/home/hb-test/images
while Homebrewery can serve the files locally from/usr/local/homebrewery/staticImages
. The above change does not include any such folder linking and putting it in place it is left as an exercise for the individual user, if that is what they should desire.