Pracuję nad projektem angularjs i jestem całkiem nowy w internecie. Co staram się osiągnąć jest prosty logowania. I wprowadziły tokenu uwierzytelniania bazowej, po stronie serwera (nodejs), a także po stronie klienta.
Wszystko wydaje się działać świetnie. Z wyjątkiem gdy próbuję
tego. $ window.location.href
Kiedy klikam logowanie, aby sprawdzić, czy mój uwierzytelnianie działa prawidłowo, mam nazwać $ http.get do autoryzowanego punktu końcowego to działa idealnie. Potem zrobić wezwanie do nodejs (służyć), aby służyć mi stronę w danym punkcie końcowym, który wymaga autoryzacji tokenu nagłówka. Ale to nie są wysyłane.
public loginClick = () => {
this.authService.login(this.user).then(msg => {
console.log(success);
this.$http.get(Config.apiEndpoint().url + '/memberinfo').then(result => {
console.log(result.data); //<== this works
var landingUrl = http:// + this.$window.location.host + /dashboard/;
this.$window.location.href = landingUrl; //<== this does not works
});
}, errMsg => {
console.log(failes);
});
}
Kod nodejs
app.get('/', moduleRoutes.root);
app.get('/dashboard/', moduleRoutes.root);
export function root(req: express.Request, res: express.Response) {
if (authorization.isAuthorized(req, res)) {
res.sendfile('./public/views/index.html');
} else {
res.sendfile('./public/views/login.html');
}
};













