2

I'm sending http request as following

this.http.post('/api/login', body)
      .subscribe(
        response => {
                   ...
                  },
               error=> {
                   ...
                  });

But in new systems it gives pending then after that it gots cancelled sometimes.

After loading one time this never happens on that system again and works fine. Basically I'm redirecting all client routes to index.html. As follows:

app.get(['/', '/login', '/dashboard'],function(req, res, next){
                    res.sendFile(path.join(__dirname,'/../public/index.html'));
                });

Where '/', '/login', '/dashboard' are routes at my client end. As follows:

@RouteConfig([
  { path: '/', redirectTo: ['/Dashboard'] },
  { path: '/login', component: Login, as: 'Login' },
  { path: '/dashboard', component: Dashboard, as: 'Dashboard' }
])
Akhilesh Kumar
  • 9,085
  • 13
  • 57
  • 95
  • Why don't you configure the server to do the redirection? – Günter Zöchbauer May 09 '16 at 10:31
  • 1
    To use `PathLocationStrategy` with Angulars router you need to have server-side support for HTML5 pushState that actually does that redirecting. Why do you do it yourself in Angular code? Could be that I misinterpret something. – Günter Zöchbauer May 09 '16 at 11:25
  • Friend, can you fetch me with a code whatever you are standing with, which will resolve the current problem I'm facing? – Akhilesh Kumar May 09 '16 at 11:39
  • Actually I don't know what your issue is. I'm just wondering why you do the rewriting on the client. This is the common issue devs run into when the server isn't configured for HTML5 pushState http://stackoverflow.com/a/36310728/217408 – Günter Zöchbauer May 09 '16 at 11:42
  • But I don't want to go for 'HashLocationStrategy' because some vendor like twitter bootstrap and other, uses Hash location for there own purpose but with absolute path I don't face those kind of problems – Akhilesh Kumar May 09 '16 at 11:49
  • I have seen others mentioned using your strategy but I have no knowlege of any implications. Maybe someone else can provide more help. – Günter Zöchbauer May 09 '16 at 11:55
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/111455/discussion-between-akhilesh-kumar-and-gunter-zochbauer). – Akhilesh Kumar May 09 '16 at 16:35

0 Answers0