0

I have on the server side a expres js. I'm serving images with:

app.use('/static', express.static(out_path));

On some querys the server return image paths. So in production that would be

https://<myApp>.com/static/<image_name>

Since I need also a dev environment the path would be

http://localhost:port/static/<image_name>

Is there an elegant solution to this problem? I could use a config or something like that, but perhaps there exist a better solution.

Thanks and best reagards

MichaelRazum
  • 789
  • 1
  • 10
  • 26

1 Answers1

0

You can set an environment variable (see here) like NODE_ENV and then parse this variable to distinguish what path you should serve. Something like:

var SITE_PATH = process.env.NODE_ENV === 'production' ? 'prod-path' : 'dev-path';
Community
  • 1
  • 1
max-lt
  • 1,037
  • 10
  • 12