aja*_*esh 6 nginx auth0 angular-cli angular
嗨,我正在尝试构建Angular 4应用程序,接下来的步骤如下 -
建立 ng build
在我的amazon ec2实例中,我运行的是apache.遵循的步骤 -
#!/bin/bash
yum install httpd -y
yum update -y
cp dist/* /var/www/html/
service httpd start
chkconfig httpd on
Run Code Online (Sandbox Code Playgroud)
一切正常,但我的应用程序auth0用于身份验证,我看到他们回调http://ip/callback
我的申请表 - 404未找到.
我尝试建立像ng build --base-href .,它没有工作!
Please help me how to build this one, please note that when I use在我当地的服务`一切都很棒.但当我尝试部署到生产时,它给出了这个错误.我非常确定在构建应用程序时我正在做的事情.
我试过nginxdocker容器,它给出了同样的错误.我的docker文件看起来像这样.
FROM nginx
COPY dist /usr/share/nginx/html
上面的docker文件有什么问题吗?
https://github.com/auth0-samples/auth0-angular-samples/tree/master/01-Login - 示例应用代码
https://manage.auth0.com/#/logs - 日志中没有错误,这意味着auth0工作正常,但我的角色出现构建错误.
确切的错误:
更新 -
我也尝试过像这样建造 -
ng build --base-href http://34.213.164.54/
而且ng build --base-href http://34.213.164.54:80/,同样的错误.
所以问题是如何缩小到我如何构建Angular App
public handleAuthentication(): void {
this.auth0.parseHash((err, authResult) => {
if (authResult && authResult.accessToken && authResult.idToken) {
window.location.hash = '';
this.setSession(authResult);
localStorage.setItem('email', profile.email);
this.verticofactoryService.registerUser(u);
this.router.navigate(['/home']);
});
} else if (err) {
this.router.navigate(['/home']);
console.log(err);
alert(`Error: ${err.error}. Check the console for further details.`);
}
});
}
Run Code Online (Sandbox Code Playgroud)
Angular 应用程序是使用简单的静态 HTML 服务器提供服务的完美候选者。您不需要服务器端引擎来动态组合应用程序页面,因为 Angular 在客户端执行此操作。
如果应用程序使用 Angular 路由器,则必须将服务器配置为在请求应用程序没有的文件时返回应用程序的主机页面 (index.html)。
假设在你的 nginx 服务器配置中添加这样的东西。try_files $uri $uri/ /index.html;
参考 - https://github.com/auth0-samples/auth0-angular-samples/tree/master/02-User-Profile
谢谢 JB Nizet,终于成功了。
| 归档时间: |
|
| 查看次数: |
2500 次 |
| 最近记录: |