Angular universal rendering for some routes only

后端 未结 1 737
夕颜
夕颜 2021-02-06 03:59

I was playing with angular universal a bit but cant find option to use server side rendering only for some pages like home page and render all other routes in standard angular w

相关标签:
1条回答
  • 2021-02-06 04:48

    In your server.ts for routes you don't want to render just do as below

    app.get('/api/**', (req, res) => { });
    
    app.get('/app/**', (req, res) => {
      console.log('not rendering  app pages');
    });
    
    app.get('/auth/**', (req, res) => {
      console.log('not rendering auth page');
    });
    

    // All regular routes use the Universal engine

    app.get('*', (req, res) => {
      res.render('index', { req });
    });
    

    Hope this helps.

    0 讨论(0)
提交回复
热议问题