node.js - Images uploaded with Node server cannot be found by Angular 2 -




i have app in angular 2, decided add real server, node js, upload documents , other things.

browser => angular [localhost:4200/api/documents] => node [localhost:3000/documents] 

this how start them using scripts in package.json

"scripts": {     "server-start": "gulp",     "client-start": "ng serve --verbose --proxy-config server.conf.json",     "start": "npm-run-all -p client-start server-start" } 

so, when run npm start starts 2 parallel processes - node js using gulp , angular using ng serve. angular front end, urls start /api redirected node. here how it's done server.config.js

{   "/api": {     "target": "http://localhost:3000",     "secure": false   } } 

node js receives stream angular image , saves in angular assets folder, uploaded image should available in angular, when try open uploaded image in browser returns me 404, not found. in case, part of .angular-cli.json

"root": "src", "outdir": "dist", "assets": [   "assets",   "favicon.ico",   "service-worker.js" ], "index": "index.html", "main": "main.ts" 

example, have existing image there before ng serve

f:\node\cms\src\assets\uploads\1.jpg 

available at, works

http://localhost:4200/assets/uploads/1.jpg 

i upload new 1 same location

f:\node\cms\src\assets\uploads\5.jpg 

but it's not available at

http://localhost:4200/assets/uploads/5.jpg 

when restart servers image becomes available. according this discussion ng serve performs deployment of angular app in background, , folder dist empty, images taken memory, , new images dropped assets won't available, correct me if wronng.

question #1: built-in angular server able handle dynamic images if added when application running in memory?

question #2: looks in complex apps ng serve brings more troubles benefits, worth try make working or you'd recommend start using ng build instead?

when running application, points build folder. not "src"

you wiping out images each time run serve or need store them in different location.

you technically storing images on "server" recommend using node retrieve paths these files.





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -