@@ -18,15 +18,21 @@ We create a file next to our project's `package.json` called `proxy.conf.json` w
18
18
19
19
You can read more about what options are available [ here] ( https://webpack.js.org/configuration/dev-server/#devserver-proxy ) .
20
20
21
- We can then edit the ` package.json ` file's start script to be
21
+ We can then add the ` proxyConfig ` option to the serve target:
22
22
23
23
``` json
24
- "start" : " ng serve --proxy-config proxy.conf.json" ,
24
+ "architect" : {
25
+ "serve" : {
26
+ "builder" : " @angular-devkit/build-angular:dev-server" ,
27
+ "options" : {
28
+ "browserTarget" : " rx-seven-project:build" ,
29
+ "proxyConfig" : " src/proxy.conf.json"
30
+ },
25
31
```
26
32
27
- Now in order to run our dev server with our proxy config, we can simply call ` npm start ` .
33
+ Now in order to run our dev server with our proxy config we can call `ng serve `.
28
34
29
- ** After each edit to the proxy.conf.json file remember to relaunch the ` npm start ` process to make your changes effective.**
35
+ **After each edit to the proxy.conf.json file remember to relaunch the `ng serve ` process to make your changes effective.**
30
36
31
37
### Rewriting the URL path
32
38
@@ -105,10 +111,16 @@ const PROXY_CONFIG = [
105
111
module.exports = PROXY_CONFIG;
106
112
```
107
113
108
- and make sure to point to the right file
114
+ Make sure to point to the right file (`.js` instead of `.json`):
109
115
110
116
```json
111
- "start" : " ng serve --proxy-config proxy.conf.js" ,
117
+ "architect" : {
118
+ "serve" : {
119
+ "builder" : " @angular-devkit/build-angular:dev-server" ,
120
+ "options" : {
121
+ "browserTarget" : " rx-seven-project:build" ,
122
+ "proxyConfig" : " src/proxy.conf.js"
123
+ },
112
124
```
113
125
114
126
### Bypass the Proxy
@@ -132,9 +144,3 @@ const PROXY_CONFIG = {
132
144
133
145
module.exports = PROXY_CONFIG;
134
146
```
135
-
136
- again, make sure to point to the right file
137
-
138
- ``` json
139
- "start" : " ng serve --proxy-config proxy.conf.js" ,
140
- ```
0 commit comments