infor-cloud / widget-sdk

Infor Widget SDK
https://infor-cloud.github.io/widget-sdk/
Other
60 stars 14 forks source link

Connect to ION API in Cloud when developing #35

Closed dhenningsver closed 6 months ago

dhenningsver commented 6 months ago

Hi, How do you proxy the ION API calls in a cloud environment. The documentation regarding the ION API seems to be related to on premise? I don't get it to work in cloud. I have tried to set the cloud url directly in the configuration.json but then I get CORS issues instead.

anhallbe commented 6 months ago

The setup is pretty much the same for on-prem and cloud:

  1. Check that the devConfiguration is included in index.html, like so: <lm-app devWidget="some.widget" devConfiguration="configuration.json"></lm-app>.
  2. In configuration.json, set the intended tenant: "ionApiUrl": "http://localhost:8083/<TENANT_GOES_HERE>".
  3. In configuration.json, set the ION API token: "ionApiToken": "<TOKEN_GOES_HERE>".
  4. In package.json, enter values in the "config" property, e.g:
"config": {
    "server_port": "8080",    // Leave as-is
    "server_path": "./Widgets",  // Leave as-is
    "proxy_local_port": "8083",  // Leave as-is, must match the port used in configuration.json ionApiUrl
    "proxy_remote_host": "domain.server.com", // Example: "mingle-ionapi.inforcloudsuite.com"
    "proxy_remote_port": "443" // Leave as-is
}

You can get the ION API token and hostname either by inspecting requests made in a "real" environment, or copy them from the UI in the API Gateway.

Finally, start the proxy with the "Start Proxy" vscode build task (Ctrl+Shift+B), or run the script in a terminal node path/to/proxy.js

dhenningsver commented 6 months ago

Thanks, your instruction worked like a charm. I missed the config part in the package.json.

anhallbe commented 6 months ago

Nice! Glad it worked out. You can also provide the same config as arguments to the proxy script, like:

node ../proxy.js 8083 the-ionapi-hostname 443

....but I personally prefer the package.json conf.