How to Deploy Angular app with Proxy Settings

前端 未结 3 2097
春和景丽
春和景丽 2021-02-13 21:49

I have a proxy config file which has API(web service) link to target to make calls to our database. This proxy config is working fine locally using npm start .<

3条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-13 22:09

    Option 1: Don't use IIS Server.

    You can create an application with node and express to serve your static files and to be your api server, which will call the right one (almost like a redirect)

    What ng serve --proxy-config probably does is to run a node server with your application exposed as static and run api's according to your configuration redirecting (calling the server) to the server.

    When we call an api from node server, there's no CORS because we don't have a hostname like an web application.


    Option 2: With IIS and a node/express application## Heading ##

    You can create an application and allow the CORS to your hostname. From this application you can expose a generic api and call the right api server.

提交回复
热议问题