1

I am trying to setup angular pwa with our application. We are using proxy.conf.json to route our apis to other backend urls. The following the content of proxy.conf.json:

{
  "/api": {
    "target": "http://localhost:7002",
    "secure": false,
    "pathRewrite": {
       "^/api": ""
    },
    "logLevel" "debug"
}

So angular routing api calls to 7002 port and this application was running on 8080 port. As we wantt to setup the pwa with our appication, it is mentioned in the angular docs to not to use "ng serve" for pwa, so we are using http-server to run this application on port 4040 after building this application, but backend api calls are also routing to the same port 4040 instead of 7002 port.

How to rewrite the backend urls of apis with http-server?

smnth90
  • 750
  • 5
  • 14
  • @GRD I think he means api server – Bálint Réthy Dec 15 '21 at 10:35
  • @BálintRéthy then Its easy to pass server url inside httpclient.get ? isnt it like that ? – GRD Dec 15 '21 at 10:37
  • Whenever angular finds a http request like "http://localhost:8080/api/users"., angular rewrites the url as "http://localhost:7002/api/users" based on this proxy.conf.json and makes a request. But I don't know how to handle the same thing using with http-server? – smnth90 Dec 15 '21 at 10:43

0 Answers0