File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
docs/documentation/stories Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -56,3 +56,31 @@ and make sure to point to the right file
56
56
``` json
57
57
"start" : " ng serve --proxy-config proxy.conf.js" ,
58
58
```
59
+
60
+ ### Bypass the Proxy
61
+
62
+ If you need to optionally bypass the proxy, or dynamically change the request before it's sent, define the configuration in proxy.conf.js e.g.
63
+
64
+ ``` js
65
+ const PROXY_CONFIG = {
66
+ " /api/proxy" : {
67
+ " target" : " http://localhost:3000" ,
68
+ " secure" : false ,
69
+ " bypass " : function (req , res , proxyOptions ) {
70
+ if (req .headers .accept .indexOf (" html" ) !== - 1 ) {
71
+ console .log (" Skipping proxy for browser request." );
72
+ return " /index.html" ;
73
+ }
74
+ req .headers [" X-Custom-Header" ] = " yes" ;
75
+ }
76
+ }
77
+ }
78
+
79
+ module .exports = PROXY_CONFIG ;
80
+ ```
81
+
82
+ again, make sure to point to the right file
83
+
84
+ ``` json
85
+ "start" : " ng serve --proxy-config proxy.conf.js" ,
86
+ ```
You can’t perform that action at this time.
0 commit comments