Angular CLI: Change REST API URL on build

后端 未结 7 1661
心在旅途
心在旅途 2021-02-02 08:58

I want to remove my local server prefix from my REST API URLs (example, http://localhost:8080) when building for production (ng build --prod).

I get that i

7条回答
  •  迷失自我
    2021-02-02 09:33

    You don't need to hard code the API_URL as mentioned above just use your environment.prod.ts file. Set-:

    1. production = true.
    2. Change the API_URL to your desired url.
    3. Now run the command ng build --prod=true

    It worked for me I guess, will work for you too.

提交回复
热议问题