From d4baf714837c976fcfc2340ad64f84e11ed1139e Mon Sep 17 00:00:00 2001 From: Clemente Raposo Date: Wed, 5 Feb 2020 10:18:22 +0000 Subject: [PATCH] Add ng serve local proxy configuration for api calls --- .gitignore | 4 ++++ README.md | 10 +++++++--- angular.json | 3 ++- proxy.conf.env.json | 7 +++++++ 4 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 proxy.conf.env.json diff --git a/.gitignore b/.gitignore index a12a1306b..9ed5802b6 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,10 @@ /vendor/ ###< symfony/framework-bundle ### +###> ng serve ### +/proxy.conf.local.json +###< ng serve ### + build/ config/ !config/.gitkeep diff --git a/README.md b/README.md index 752de88ea..9dfc26ccb 100755 --- a/README.md +++ b/README.md @@ -44,6 +44,10 @@ find . -type d -exec chmod 0755 {} \; find . -type f -exec chmod 0644 {} \; chmod +x bin/console ``` -5. Run `bin/console orm:schema-tool:update --force` -6. Run `npm install` -7. Run `ng build` \ No newline at end of file +5. Go back to root folder +6. Run `bin/console orm:schema-tool:update --force` +7. Run `npm install` +8. Setup proxy config for `ng serve` + - Copy `proxy.conf.env.json` to `proxy.conf.local.json` + - Replace `"target": "http//:"` with your api url +9. Run `ng build` or `ng serve` \ No newline at end of file diff --git a/angular.json b/angular.json index 74f22572f..53c247274 100644 --- a/angular.json +++ b/angular.json @@ -60,7 +60,8 @@ "serve": { "builder": "@angular-devkit/build-angular:dev-server", "options": { - "browserTarget": "SuiteCRM:build:serve" + "browserTarget": "SuiteCRM:build:serve", + "proxyConfig": "./proxy.conf.local.json" }, "configurations": { "production": { diff --git a/proxy.conf.env.json b/proxy.conf.env.json new file mode 100644 index 000000000..e73112a2b --- /dev/null +++ b/proxy.conf.env.json @@ -0,0 +1,7 @@ +{ + "/api/*": { + "target": "http//:", + "secure": false, + "changeOrigin": true + } +} \ No newline at end of file