Difficulty with absolute and relative paths in Express

后端 未结 5 676
挽巷
挽巷 2021-01-24 17:59

I have a route for an API in an Express app that looks like this:

app.get(\'/:username/:bookmark/\', function(req, res) {

  // do stuff

})

As

5条回答
  •  温柔的废话
    2021-01-24 18:34

    If you're at /username/bookmark/ and you link the CSS like this

    
    

    or this

    
    

    It will resolve to /username/bookmark/css/main.css. But you want to link in like this

    
    

    The problem is, that the .static-middleware only routes at the base path / instead of all routes you defined.

提交回复
热议问题