Syntax Error in Angular App: Unexpected token <

后端 未结 30 2103
独厮守ぢ
独厮守ぢ 2020-12-02 20:16

I have an Angular app which runs perfectly in my local and production environment.. After a tiny change I made, I ran the app locally and it works fine.. Then I built the pr

30条回答
  •  借酒劲吻你
    2020-12-02 20:18

    In my case was a mismatch route path in the server file. the route to statics must be the dir containing both the index.html and the assets dir, not the assets dir itself.

    app.use(express.static(path.resolve(__dirname,'/dist')));
    
    app.get('/*', function (req, res) {
      res.sendFile(path.join(path.resolve(__dirname, '/dist/index.html')));
    });
    

提交回复
热议问题