Search code examples
angularswaggerswagger-codegen

How to configure port using Swagger Codegen


I am building an Angular application and trying to connect to the backend via Swagger Codegen. Code generates fine. The backend is running locally.

The thing is that the frontend always fires the request to port 4200 where Angular is running.

How can I change that since the backend is running on port 8081?


Solution

  • You can find it in the Angular docs. There are usually 2 options for this.

    use proxy to match all the requests from the server. Here's the detail: link

    Configure server URL variable in environment.ts and use it in every service. Check it out: link