Angular pwa, how can I make http-server (running on localhost:8080) to work with a nodejs server running on localhost:3333?

左心房为你撑大大i 提交于 2021-01-27 23:13:46

问题


When I serve the web-app on port 3330, I can make the webapp working on port 3333 using --proxy ./src/proxy.config.json, but I don't know how to make http-server to make to work at the same way

"start": "ng serve -o --port 3330 --watch --proxy-config ./src/proxy.config.json",
"pwa": "http-server -p 8080 -c-1 dist/satoshi-pwa --proxy http://localhost:3333",

proxy.config.json:

{
  "/api": {
    "target": "http://localhost:3333",
    "secure": false,
    "changeOrigin": true,
    "pathRewrite": {
      "^/api": "/"
    }
  }
}

environment.ts:

export const environment = {
  production: true,
  apiUrl: 'http://localhost:3333/api'
};

来源:https://stackoverflow.com/questions/62504521/angular-pwa-how-can-i-make-http-server-running-on-localhost8080-to-work-with

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!