I am using node.js and the express framework to send a get request for an image by appending the image to the body using $('body').append('<img src="images/image.gif?34567">')
. When I send the request, the console is logging GET /images/image.gif?34567 200 1.223 ms
, but it won't run the functions inside of my router for the route to that image.
router.get('/images/*', function(req, res) {
console.log('Accessed image folder...')
var requestURL = url.parse(req.url,true);
//ATTEMPT to capture request
if(requestURL.pathname == '/images/image.gif') {
console.log("Fetching image...")
}
});
I was also trying to use the specific route: router.get('/images/image.gif', function(req, res) {
, and tried following this example.
How can I make the GET
router work when requesting a specific image inside of the images directory?