Angular-CLI with proxy (different frontend and backend endpoint ports / domains)
Proxy file and 'ng' command to allow the front-end to call a backend endpoint, allowing it to send and receive cookies between other HTTP protocol related data. Scenario: When using ng-serve (local development server) and having the backend in a different endpoint. *This is a catch all configuration, but the wildcard can be switched over to any path, and multiple entries can be added in the JSON file.
proxy.api.json
''' { "*": { "target": "http://localhost:3232", "secure": false, "logLevel": "debug", "changeOrigin": true } } '''
angular-cli (webpack dev server v1.3.2)
'ng serve --proxy-config proxy.api.json --port 4400'
package.json (shortcut to start backend and frontend, and perform CI/CD tasks)
''' { "name": "ctw-rt1", "version": "0.0.0", "private": true, "scripts": { "frontend": "ng serve --proxy-config proxy.api.json --port 4400", "backend": "nodemon ./bin/www", "build": "docker build -t ctw-recipes .", "container": "docker stop recipes; docker rm recipes; docker run -it -p 5858:5858 -p 4200:4200 -p 3232:3232 -v "$PWD:/var/app" -v $PWD/node_modules:/var/app/node_modules --name recipes ctw-recipes bash; exit 0", "container-shell": "docker exec -it recipes bash; exit 0", "clean": "docker stop recipes; docker rm recipes; docker rmi ctw-recipes; exit 0", "deploy": "./deploy.sh", "deploy-frontend": "./deploy-client.sh", "deploy-backend": "./deploy-production.sh" }, "dependencies": { "body-parser": "~1.15.2", "connect-mongostore": "^0.1.4", "cookie-parser": "~1.4.3", "cors": "^2.8.3", "debug": "~2.2.0", "epa": "^0.2.1", "express": "~4.14.0", "express-session": "^1.13.0", "firebase": "^4.3.0", "firebase-admin": "^5.2.1", "iam": "^0.1.0", "jade": "~1.11.0", "mongoose": "^4.7.8", "morgan": "~1.7.0", "nanit": "^0.3.1", "rabbot": "^1.0.8", "rabbus": "^0.8.2", "serve-favicon": "~2.3.0", "smtp-connection": "^4.0.2" }, "devDependencies": { "@angular/cli": "^1.3.2" } } '''
Created on 9/14/2017