angular 17, add proxy in angular multiproject?

114 views Asked by At

I tried to add the proxy and Rewrite the URL path according to the angular documentation guidelines, but without success, the docs I have followed here: https://angular.io/guide/build#rewrite-the-url-path . What is the correct way to add angualr proxy in an angular multiproject, with angular 17?

1

There are 1 answers

0
Rの卄IT On

Try these few steps to add proxy configuration for angular in a multi-project setup

  1. in your root project, create a file called - `proxy.config.json
  2. Add the proxy configuration in the file:
{
 "/api": {
   "target": "http:locahost:3000",
   "secure": false
  }
}

This way proxy API request to http:locahost:3000

  1. Now in the angular.json file, under the each project, add the proxyConfig settings like
"architect":{
 "serve": {
   "options": {
     "proxyConfig": "proxy.config.json"
  }
 }
}

I hope this will help you. Cheers