vyakymenko / angular-seed-express

[DEPRECATED, Please use https://github.com/vyakymenko/angular-express] Extensible, reliable and modular starter project for Angular 7 with statically typed build AoT compilation, Express server and PM2 Daemon.

Home Page:https://github.com/vyakymenko/angular-seed-express

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Name-List error

Meistercoach83 opened this issue · comments

After npm install && npm start my browser opens correctly. The page is show, but when trying to access http://localhost:9001/api/name-list the server throws an error

NameListService.prototype.handleError(error=Response { _body=Event error, status=0, ok=false, mehr...})name-li...vice.js (Zeile 29)
CatchSubscriber.prototype.error(err=Object { type="object"})catch.js (Zeile 51)
Subscriber.prototype._error(err=Object { type="object"})Subscriber.js (Zeile 127)
Subscriber.prototype.error(err=Object { type="object"})Subscriber.js (Zeile 101)
XHRConnection/this.response</onError(err=Object { type="object"})http.umd.js (Zeile 1167)
Zone</ZoneDelegate</ZoneDelegate.prototype.invokeTask(targetZone=Object { type="object"}, task=Object { type="object"}, applyThis=Object { type="object"}, applyArgs=Object { type="object"})zone.js...8994086 (Zeile 356)
NgZoneImpl/this.inner<.onInvokeTask(delegate=Object { type="object"}, current=Object { type="object"}, target=Object { type="object"}, task=Object { type="object"}, applyThis=Object { type="object"}, applyArgs=Object { type="object"})core.umd.js (Zeile 9091)
Zone</ZoneDelegate</ZoneDelegate.prototype.invokeTask(targetZone=Object { type="object"}, task=Object { type="object"}, applyThis=Object { type="object"}, applyArgs=Object { type="object"})zone.js...8994086 (Zeile 355)
Zone</Zone</Zone.prototype.runTask(task=Object { type="object"}, applyThis=Object { type="object"}, applyArgs=Object { type="object"})zone.js...8994086 (Zeile 256)
ZoneTask/this.invoke()

@Meistercoach83 , before npm start, run the server middleware
node app.sever.dev.js

In future middleware runner will be included to npm start.

Also got error that it's unable to load the list.
Made sure to start server before running npm start. The error is:

XMLHttpRequest cannot load http://localhost:9001/api/name-list. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:5555' is therefore not allowed access.

Basically there are two servers. One is the app api and another one is there just for the purposes of serving angular app.
The quick hacky solution (that I don't think is acceptable) is to add headers on the server.
The proper way to fix this would be somehow combining the two servers.

@DmitryEfimenko , you are right, my false in routes.
Fixed:
33a5ee1

In future I will combine them.

that fix broke serving list in prod because app.get('/*', renderIndex); now runs before require('./routes')(app); and therefore intercepts requests to api and serves index page instead.

@DmitryEfimenko , I have add a temporary hotfix, that is 100% fix this issue.
The reason is, my Redis implementation work :)