universal: Universal App fails on http://localhost:4200 but works on http://localhost:4200/index.html
- I’m submitting a …
- [x] bug report
- [ ] feature request
- [ ] support request => Please do not submit support request here, see note at the top of this template.
- What modules are related to this Issue?
- [ ] aspnetcore-engine
- [ ] common
- [x] express-engine
- [ ] hapi-engine
- [ ] module-map-ngfactory-loader
- What is the current behavior?
I followed the instructions on the angular-cli wiki to use universal, all compiled correctly with no errors.
The Universal App fails on http://localhost:4200
the first time it loads but works on http://localhost:4200/index.html
It works fine if I just run a http-server on client folder.
After loading http://localhost:4200/index.html
the first time, then http://localhost:4200
is accessible.
The error I receive is 500 with a response of :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Error</pre>
</body>
</html>
Which seems to be a server error.
- Please tell us about your environment:
"dependencies": {
"@amcharts/amcharts3-angular": "^2.0.3",
"@angular/animations": "5.2.10",
"@angular/cdk": "5.2.3",
"@angular/common": "5.2.10",
"@angular/compiler": "5.2.10",
"@angular/core": "5.2.10",
"@angular/forms": "5.2.10",
"@angular/http": "5.2.10",
"@angular/material": "5.2.3",
"@angular/platform-browser": "5.2.10",
"@angular/platform-browser-dynamic": "5.2.10",
"@angular/platform-server": "5.2.10",
"@angular/router": "5.2.10",
"@angular/service-worker": "5.2.10",
"@ngrx/effects": "5.1.0",
"@ngrx/router-store": "5.0.1",
"@ngrx/store": "5.1.0",
"@ngrx/store-devtools": "5.1.0",
"@nguniversal/express-engine": "^5.0.0",
"@nguniversal/module-map-ngfactory-loader": "^5.0.0",
"@ngx-share/buttons": "^5.0.0-beta.3",
"@ngx-share/core": "^5.0.0-beta.3",
"@nrwl/nx": "0.8.0",
"@swimlane/ngx-datatable": "^11.1.5",
"@toverux/ngx-sweetalert2": "^3.0.1",
"amcharts3": "github:amcharts/amcharts3",
"angular2-jwt": "^0.2.3",
"classlist.js": "^1.1.20150312",
"core-js": "^2.4.1",
"google-libphonenumber": "^3.0.9",
"lodash": "^4.17.4",
"ng2-cookies": "^1.0.12",
"ng2-pagination": "^2.0.1",
"ngx-chips": "^1.6.1",
"ngx-clipboard": "9.1.3",
"ngx-order-pipe": "^2.0.1",
"ngx-toastr": "^8.3.2",
"ngx-uploader": "^4.2.4",
"papaparse": "^4.3.6",
"query-string": "^5.1.0",
"raven-js": "^3.24.2",
"rxjs": "^5.5.10",
"socket.io-client": "^2.0.4",
"sweetalert2": "^7.0.6",
"tm-intro.js": "^2.9.0-alpha.1",
"vis": "^4.21.0",
"web-animations-js": "^2.3.1",
"zone.js": "^0.8.26"
},
"devDependencies": {
"@angular-devkit/core": "0.5.7",
"@angular-devkit/schematics": "0.5.7",
"@angular/cli": "1.7.4",
"@angular/compiler-cli": "5.2.10",
"@angular/language-service": "5.2.10",
"@nrwl/schematics": "0.8.0",
"@types/intro.js": "^2.4.3",
"@types/jasmine": "~2.5.53",
"@types/jasminewd2": "~2.0.2",
"@types/node": "~6.0.60",
"@types/vis": "^4.21.0",
"codelyzer": "~3.1.1",
"jasmine-core": "~2.6.2",
"jasmine-spec-reporter": "~4.1.0",
"karma": "~1.7.0",
"karma-chrome-launcher": "~2.1.1",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"ngrx-store-freeze": "^0.2.0",
"npm-run-all": "^4.1.2",
"prettier": "1.10.2",
"protractor": "~5.1.2",
"ts-loader": "^3.5.0",
"ts-node": "~3.2.0",
"tslint": "~5.3.2",
"typescript": "2.6.2",
"webpack-node-externals": "^1.6.0"
}
- Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, gitter, etc)
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 4
- Comments: 21
@RicardoVaranda , could you resolve this issue before? I noticed that the express server was not serving index.html simply. Please use
res.sendFile()
, instead ofres.render()
Same here, it throws me
Cannot read property 'originalUrl' of undefined
presumably coming from https://github.com/angular/universal/blob/master/modules/express-engine/src/main.ts#L87 judging by stacktrace, index.html works fine for sure