nginx 错误 'Cannot match any routes' 与 Angular 2 路由器 3.0.0.-alpha.7
nginx error 'Cannot match any routes' with Angular 2 router 3.0.0.-alpha.7
nginx 似乎不适用于 Angular 2 RC3 路由器的生产版本。我收到以下错误:
Error: Uncaught (in promise): Error: Cannot match any routes: ''
at s (zone.js:538)
at zone.js:515
at t.invoke (zone.js:323)
at Object.onInvoke (ng_zone_impl.js:46)
at t.invoke (zone.js:322)
at t.run (zone.js:216)
at zone.js:571
at t.invokeTask (zone.js:356)
at Object.onInvokeTask (ng_zone_impl.js:37)
at t.invokeTask (zone.js:355)
我的nginx配置很简单:
listen 8080;
server_name localhost;
charset utf-8;
location / {
root /Users/JARVIS/src/web/ui/dist;
index index.html index.htm;
}
我无法判断这是配置问题、新路由器问题还是编译方式问题。我正在使用 angular2-webpack-starter。此问题仅发生在 nginx 中托管的产品构建中。在开发服务器中一切正常。
我的路线非常简单:
export const ChromeRoutes: RouterConfig = [
{
path: '',
component: Chrome,
canActivate: [AuthGuard], // this protects all child routes
children: [
{ path: 'dashboards', component: Dashboards },
{ path: 'inventory', component: Inventory },
{ path: 'content', component: Content },
{ path: 'settings', component: Settings },
{ path: '', redirectTo: '[/dashboards]' }
]
}
我试过将 '' 更改为 'chrome',但没有任何更改。有或没有 redirectTo 条目都没有关系。
编辑:
我的完整路线定义通过 JSON.stringify()...
javascript
[{
"path": "login",
"terminal": true
}, {
"path": "",
"canActivate": [null],
"children": [{
"path": "dashboards"
}, {
"path": "inventory"
}, {
"path": "content"
}, {
"path": "settings"
}]
}, {
"path": "inventory",
"canActivate": [null],
"children": [{
"path": "",
"terminal": true
}, {
"path": ":id"
}]
}]
如果 <head>
中有 <base href=".">
,请尝试将其更改为 <base href="/">
添加terminal: true
空路径路由
{ path: '', redirectTo: '[/dashboards]': pathMatch: 'full' }
<= RC.3
{ path: '', redirectTo: '[/dashboards]': terminal: true }
nginx 似乎不适用于 Angular 2 RC3 路由器的生产版本。我收到以下错误:
Error: Uncaught (in promise): Error: Cannot match any routes: ''
at s (zone.js:538)
at zone.js:515
at t.invoke (zone.js:323)
at Object.onInvoke (ng_zone_impl.js:46)
at t.invoke (zone.js:322)
at t.run (zone.js:216)
at zone.js:571
at t.invokeTask (zone.js:356)
at Object.onInvokeTask (ng_zone_impl.js:37)
at t.invokeTask (zone.js:355)
我的nginx配置很简单:
listen 8080;
server_name localhost;
charset utf-8;
location / {
root /Users/JARVIS/src/web/ui/dist;
index index.html index.htm;
}
我无法判断这是配置问题、新路由器问题还是编译方式问题。我正在使用 angular2-webpack-starter。此问题仅发生在 nginx 中托管的产品构建中。在开发服务器中一切正常。
我的路线非常简单:
export const ChromeRoutes: RouterConfig = [
{
path: '',
component: Chrome,
canActivate: [AuthGuard], // this protects all child routes
children: [
{ path: 'dashboards', component: Dashboards },
{ path: 'inventory', component: Inventory },
{ path: 'content', component: Content },
{ path: 'settings', component: Settings },
{ path: '', redirectTo: '[/dashboards]' }
]
}
我试过将 '' 更改为 'chrome',但没有任何更改。有或没有 redirectTo 条目都没有关系。
编辑:
我的完整路线定义通过 JSON.stringify()...
javascript
[{
"path": "login",
"terminal": true
}, {
"path": "",
"canActivate": [null],
"children": [{
"path": "dashboards"
}, {
"path": "inventory"
}, {
"path": "content"
}, {
"path": "settings"
}]
}, {
"path": "inventory",
"canActivate": [null],
"children": [{
"path": "",
"terminal": true
}, {
"path": ":id"
}]
}]
如果
<head>
中有<base href=".">
,请尝试将其更改为<base href="/">
添加
terminal: true
空路径路由
{ path: '', redirectTo: '[/dashboards]': pathMatch: 'full' }
<= RC.3
{ path: '', redirectTo: '[/dashboards]': terminal: true }