Routing error with angular.js and express

后端 未结 2 1449
臣服心动
臣服心动 2021-02-06 16:44

I am trying to do routing with angular.js around /parent root, which works if I\'m using anchor links, etc (aka routing handled purely from angular. For instance, a link that ha

相关标签:
2条回答
  • 2021-02-06 17:13

    This is a newly introduced "change of behavior" (or bug).

    Try using the base tag :

    <base href="/" />
    
    0 讨论(0)
  • 2021-02-06 17:18

    You're serving your JS/CSS via /parent as well:

    ... http://localhost:3000/parent/javascripts/jquery.js
                             ^^^^^^^
    

    So if you declare your routes before you declare the express.static middleware, your catch-all route will handle all JS/CSS requests.

    You should use a setup similar to this:

    // express.static() first...
    app.use('/parent', express.static(__dirname + '/public'));
    
    // ...followed by your catch-all route (only one needed)
    app.get('/parent*', function(req, res) {
      res.render('main')
    });
    
    0 讨论(0)
提交回复
热议问题