代码之家  ›  专栏  ›  技术社区  ›  Bjarne Gerhardt-Pedersen

Chrome/Internet explorer浏览器刷新(F5、ctrl+R、刷新箭头等)无法在远程服务器上使用Angular(2+)项目[关闭]

  •  3
  • Bjarne Gerhardt-Pedersen  · 技术社区  · 8 年前

    我对远程服务器上部署的Angular(2+)项目的简单手动刷新(F5、ctrl+R、刷新箭头等)操作有问题。

    在远程服务器上,忽略任何刷新(F5、ctrl+R等)。我没有发现任何错误,没有找不到任何页面,什么都没有-浏览器只是停留在当前页面上,没有任何更改或刷新。

    在网络选项卡中,它甚至不向服务器发送请求。

    我可以强制刷新的唯一方法是手动更改URL。

    注:唯一明显的区别是远程服务器在https://protocol上运行。

    2 回复  |  直到 8 年前
        1
  •  0
  •   Mark Dreyer    8 年前

    听起来像是角度一侧的不良路由器配置导致了路由循环。我会仔细检查你的应用程序。单元ts路线。您还可以添加enableTracing来诊断路由:

    { enableTracing: true }

    应用程序。单元输电系统

    const appRoutes: Routes = [
      { path: 'crisis-center', component: CrisisListComponent },
      { path: 'hero/:id',      component: HeroDetailComponent },
      {
        path: 'heroes',
        component: HeroListComponent,
        data: { title: 'Heroes List' }
      },
      { path: '',
        redirectTo: '/heroes',
        pathMatch: 'full'
      },
      { path: '**', component: PageNotFoundComponent }
    ];
    
    @NgModule({
      imports: [
        RouterModule.forRoot(
          appRoutes,
          { enableTracing: true } // <-- Add this to debug routes
        )
      ]
    })
    export class AppModule { }
    
        2
  •  0
  •   Bjarne Gerhardt-Pedersen    8 年前

    好的,发现问题:

    路由请求没有由服务器NginX配置处理,该配置在一个无主体204中解决,Chrome开发人员工具将其视为无效而丢弃,使其看起来好像没有发出任何请求。

    删除204错误处理后,错误在Chrome中显示为404,因此不是角度问题:)

    推荐文章