st. skip 'path' part of URI if it's already provided in request


my st instance configured with

var mount = st({ 
  path: './app/',
  url: '/', // defaults to path option
  index: 'index.html',
  cache: {
    fd: none,
    content: none

so when I send request to res/img/1.jpg it goes to ./app/res/img/1.jpg That's pretty much clear. But if have some requests to app/res/img/1.jpg then it redirect this requests to ./app/app/res/img/1.jpg and of course find nothing, because I have different file structure.

Is it possible to configure st or maybe add some custom code to skip path adding if it's already exist in URI? Or maybe it possible some way to add specific path which handles different, like some exclusions?

Problem courtesy of: silent_coder


I don't know if it possible to do that with st directly, but you simply could add code to rewrite url if it met for some cases.

ad code like

var exceptions = { 

function rewriteUrl(req){
   req.url = exceptions[req.url];

and then call that function before st method calling

http.createServer(function (req, res) {
  mount(req, res);
Solution courtesy of: Ph0en1x


There is currently no discussion for this recipe.

This recipe can be found in it's original form on Stack Over Flow.