ng:proxy_to_back-end_for_development

Proxy to Back-end For Development

  1. Create a file call proxy.conf.json in the root directory of your project.
  2. Fill the config in proxy.conf.json:
      {
      "/BACKEND_SERVER_URL/*": {
        "target": "http://localhost:8080/BACKEND_SERVER_URL/",
        "secure": false,
        "logLevel": "debug",
        "changeOrigin": false,
        "pathRewrite": {
            "^/BACKEND_SERVER_URL": ""
        }
        , "headers": {"ipaddress":"127.0.0.1"}
      }
    }
  3. Start your back-end server. Assume your back-end server url is http://localhost:8080/BACKEND_SERVER_URL/
  4. Start the front-end with:
    ng s --base-href /YOUR_BASE_URL/ --deploy-url /BACKEND_SERVER_URL/ --proxy-config proxy.conf.json
  5. Now your front-end http request will automatically redirect by angular from port 4200 to 8080 with the relative back-end url.
  • ng/proxy_to_back-end_for_development.txt
  • Last modified: 2019/01/02 09:56
  • by chongtin