I'm making a web app that runs on a node express webserver. I have the routes currently setup like this:
app.all('*', function(req, res){
var url = req.originalUrl;
if(url == '/'){
res.render('index.html');
} else {
console.log("**USING * HANDLER");
var string = url.substr(1, url.length);
res.render(string);
}
});
I have it setup that way cause it takes care of at least 15 links from the index.html
file in one pass.
Now below that, I also have:
app.get('/proxy*', function (req, res) {
console.log('**USING /proxy HANDLER');
//return proxy.proxyRequest(req, res, proxyOptions);
});
That's because my server makes some requests like:
GET /proxy.php?url=http%3A%2F%2Fa.tile.cloudmade.com%2FBC9A493B41014CAABB98F0471D759707%2F997%2F256%2F0%2F0%2F0.png
I need those requests to be handled separately. The problem is it seems like a lot of stuff gets by without any printing. Here's a list of some of the GETS:
**USING * HANDLER
GET / 304 8ms
**USING * HANDLER
GET /leaflet.html 304 5ms
GET /leaflet/dist/leaflet.js 304 1ms
GET /js/jquery/jquery-1.4.2.js 304 1ms
GET /js/osgjs/osg-debug-0.0.7.js 304 2ms
GET /js/osgjs/osg-extras.js 304 3ms
GET /js/osgearth/FunctionLocation.js 304 3ms
GET /js/osgearth/osgearth.js 304 4ms
GET /js/osgearth/ShaderFactory.js 304 2ms
GET /js/osgearth/VirtualProgram.js 304 1ms
GET /js/osgearth/Extent.js 304 2ms
GET /js/osgearth/EllipsoidModel.js 304 1ms
GET /js/osgearth/Profile.js 304 2ms
GET /js/osgearth/GeodeticProfile.js 304 2ms
GET /js/osgearth/MercatorProfile.js 304 3ms
GET /js/osgearth/TileKey.js 304 3ms
GET /js/osgearth/ImageLayer.js 304 2ms
GET /js/osgearth/HeightField.js 304 2ms
GET /js/osgearth/ElevationLayer.js 304 3ms
And that's it. It prints USING * HANDLER
for the GETS I actually manually make myself. So when I go to the server URL for /
, and when I then click on the link for leaflet.html
After that, all the GETS made by the server return successfully but it never prints. It also never prints for the proxy route. What gives? And how do I fix this?
Just a quick recap how this was solved;
It turns out that express.static
was configured to have priority to serve files that existed in the file system before any routes were called.
Removing the static files that weren't to be served (proxy.php in this case) from the file system allowed the route handler to be called as intended instead of static serving the content of proxy.php.