0

I have a node.js with express running on Heroku linked to a github repository, it is serving a website which also contains a "gallery" section. The pictures in the gallery are loaded in very high res by other non tech-savvy admins, to prevent huge data usage from mobile users.

I would like the express.js server to downscale and compress the images coming from a certain path when requested by a normal get request before sending them as reply. Could you help me understand how can i "intercept" those requests ? or at least route me in a certain direction ?

Sorry to ask it here and like this, but i tryed looking many wikis and some questions here on stackoverflow but none seems to talk about what i'm searching (at least from my understanding).

Thank you for your time!

  • Why you are serving High-res images? Convert images at once and serve compressed images always. – Gaurav Gandhi Feb 06 '19 at 08:50
  • unfortunately i cannot, else i'd have done it, my server is running on free heroku, so no storage, it's linked to a github repo that is deployed to it on commit – Gianmarco Cassedy Poggi Feb 07 '19 at 09:27
  • Okay, can you not push compressed images on GitHub?. One question, you want to serve lo-res images to all users or some/specific users? – Gaurav Gandhi Feb 07 '19 at 10:22
  • I want to serve them to any user, unfortunately as i said above, imgs are pushed by non tecchy admins and i would like this to be handled by the server (If i can i prefer being able to avoid going compress an image everytime they upload a new one (speaking of > 1k images here)) Thank you for you patience and understanding – Gianmarco Cassedy Poggi Feb 07 '19 at 11:03

0 Answers0