Proxy Configuration

The browser enforces the so-called same-origin policy that restricts any outgoing calls a website can make to be targeted at the same protocol, host and port-number for security reasons. Hence we are not allowed to call a Blueriq Runtime on e.g. http://localhost:8080/ from our Angular page that is served on http://localhost:4200/ because the port number does not match. Hence, we need to proxy all calls to the Blueriq Runtime through Angular's development server; create a file called proxy.conf.json in the root of the project containing:

{
  "/Runtime": {
    "target": "http://localhost:8080",
    "pathRewrite": {
      "^/Runtime": "/Runtime/server"
    },
    "secure": false
  }
}

This configuration causes all requests to http://localhost:4200/Runtime/* to be redirected to http://localhost:8080/Runtime/server/*

The above example assumes that the Runtime is served from an application server such as Tomcat or JBoss. In that case, the Runtime is exposed under the so-called context-root /Runtime. When running as standalone jar, such context-root is not present causing the above example to become incorrect. Replace "/Runtime/server" with "/server" in order for this to be taken into account.

The Blueriq API requires cookies to be sent with each request. If you experience connection issues, verify that Blueriq's cookies correspond with the outgoing request URLs and are sent with each API request.

For more in-depth documentation on Angular's proxy configuration, please head over to the official documentation.

If you find that different team members have to change the proxy configuration to fit their needs, consider adding proxy.conf.json to .gitignore and add a sample configuration in proxy.conf.json.example instead.

Activate proxy

The easiest way to activate the proxy is to configure the proxy.conf.json file as default. Edit angular.json in the root of the project and extend the "serve" architect with the proxy configuration file as default option:

  "serve": {
    "builder": "@angular-devkit/build-angular:dev-server",
    "options": {
      "browserTarget": "your-application-name:build",
      "proxyConfig": "proxy.conf.json"
    },

result-matching ""

    No results matching ""