在本地计算机上,当我将应用程序下载到服务器时,一切对我来说都工作正常,确认链接停止工作,当我经过它时,我得到此页面的错误不存在,我不知道如何修复此错误及其相关内容,因为在控制台中没有错误,我无法抓住它们。
import { Component, Inject, forwardRef } from '@angular/core';
import { Router, ActivatedRoute, Params } from '@angular/router';
import { Location } from '@angular/common';
import { AuthService } from '../services/auth';
@Component({
templateUrl: '../templates/confirm-email.html'
})
export class ConfirmEmailComponent {
loading: boolean = true;
constructor(
private router: Router,
private route: ActivatedRoute,
private location: Location,
@Inject(forwardRef(() => AuthService)) public _authService: AuthService,
) {
this.checkConfirmationToken();
}
checkConfirmationToken() {
this.route.queryParams
.subscribe((params: Params) => {
let token: string = params['confirmation_token'];
if (params && token) {
this._authService.checkConfirmationToken(token)
.then(res => {
this.loading = false;
});
} else {
this.router.navigate(['/login']);
}
});
}
}
checkConfirmationToken(confirmation_token: string): Promise<Object> {
const url = `${this.baseUrl}/api/users/${confirmation_token}/confirm_email`;
return this.http.get(url)
.toPromise()
.then(res => res.json())
.catch(error => {
this.router.navigate(['/login']);
this.handleError(error, 'Could not confirm email address!');
});
}
<p>Hello <%= @user.first_name %>!</p>
<p>
Thanks for registering! To confirm your registration click the link below.
</p>
<p>
<%= link_to("Confirm my Email", "#{@origin}/confirm_email?confirmation_token=#{@user.confirm_token}") %>
</p>
答案 0 :(得分:1)
在本地计算机上,您使用ng serve
启动应用程序。这将启动webpack并正确配置。在heroku上,您可以使用package.json中的"start": "node server.js"
。但是您的server.js包含指向index.html的错误路径。
您必须更改
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname, 'build', 'index.html'));
});
到
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname, 'dist', 'index.html'));
});