Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Angular 15: Proxy Config not Working or Deducted

I freshly created a new Angular 15 App, and tried to run with proxy-config property but the proxy is not deducted or not working at all.

enter image description here

The source code is in

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

https://github.com/jonesprabu/custom-form-elements/blob/main/src/proxy.conf.json

The Api call is in

https://github.com/jonesprabu/custom-form-elements/blob/main/src/app/services/manage-students.service.ts#:~:text=const%20students%24%20%3D%20this.http.get%3CStudent%5B%5D%3E(%60%24%7Benvironment.api%7D/students%60)%3B

enter image description here

The actual working api:
enter image description here

Please help me in find where I am going wrong with this project?

>Solution :

with current config api call will be sent to :3333/api/students while what you want to get is just :3333/students. To achieve such behavior add pathRewrite option to the proxy config

  "/api": {
    "target": "http://localhost:3333",
    "secure": false,
    "pathRewrite": {
      "^/api": ""
    }
  }
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading