Skip to content

MindConnect-NodeJS - Development Proxy

The CLI comes with a development proxy which can be used to kickstart your development. It provides an endpoint at your local machine at

http://localhost:7707

which will authenticate all requests using either one of:

First you should deploy an application to your tenant and configure its user rights. (any frontend app will do, including just an empty index.html. The important part is that you have configured the Insights Hub API scopes for your application).

api roles

After that navigate to your application and create the MDSP_HOST, MDSP_SESSION and MDSP_XSRF_TOKEN like this (example bash shell, see setting up the cli for PowerShell and CMD examples

export MDSP_HOST="castidev-sdk-castidev.eu1.mindsphere.io"
export MDSP_SESSION="NzBi...Zl"
export MDSP_XSRF_TOKEN="fed5edc5-...2565238c114"

After that the proxy will authorize all requests to Insights Hub as if the app would be deployed and if you would be logged in.

mc dev-proxy

credential auth

Developing with Application Credentials

First you should deploy an application to your tenant as before. After that navigate to AppCredentials section in your developer cockpit and issue app credentials for your application.

app credentials

Configure the CLI using the

mc service-credentials

command and select your application if you have multiple credentials configured.

Start the proxy using the -mode credentials switch.

mc dev-proxy --mode credentials --passkey <yourpasskey>

After that the proxy will authorize all requests to Insights Hub with selected Application Credentials.

credential auth

Development Proxy options

Run mc dev-proxy --help for options:

Usage: mc dev-proxy|px [options]

starts development proxy (optional passkey) *

Options:
  -m, --mode [credentials|session]  service/app credentials authentication of
                                    session authentication (default: "session")
  -o, --port <port>                 port for web server (default: "7707")
  -r, --norewrite                   don't rewrite hal+json urls
  -w, --nowarn                      don't warn for missing headers
  -d, --dontkeepalive               don't keep the session alive
  -v, --verbose                     verbose output
  -s, --session <session>           borrowed SESSION cookie from brower
  -x, --xsrftoken <xsrftoken>       borrowed XSRF-TOKEN cookie from browser
  -h, --host <host>                 the address where SESSION and XSRF-TOKEN
                                    have been borrowed from
  -t, --timeout <timeout>           keep alive timeout in seconds (default:
                                    "60")
  -k, --passkey <passkey>           passkey
  --help                            display help for command

  Examples:

    mc dev-proxy                                 runs on default port (7707) using cookies
    mc dev-proxy --port 7777 --passkey passkey   runs on port 7777 using app/service credentials

  Configuration:

        - create environment variables: MDSP_HOST, MDSP_SESSION and MDSP_XSRF_TOKEN using borrowed cookies

Community

Connect and Collaborate with Industrial Professionals and Join the Community!

Click to load comments