simple-dt-dev-proxy-plugin

0.0.1 • Public • Published

Overview

A simple extension for Dynatrace development tools, enabling the routing of certain platform calls to locally running services.

How to use it?

  1. Checkout this project.

  2. Build the project using the following command:

    npm run build
    
  3. Open the Dynatrace App where you wish to use a local platform service and configure the plugin. To activate the plugin, configure it in the 'app.config.ts' file by specifying the path to your 'dt-dev-proxy-plugin/dist' folder. Below is an example:

     const config: CliOptions = {
        environmentUrl: 'https://${yourtenant}.dev.apps.dynatracelabs.com/',
        plugins: ["../../dt-dev-proxy-plugin/dist"], //this need to point to the dist folder generated by the build in step1
        icon: './assets/davis-icon.png',
        app: {}
     }
  4. Now, start your app using 'npm start' or your preferred startup script. During the startup process, you should see the following message:

      '<yourRootFolder>/proxy-config.yaml' does not exist. Will create 'proxy-config.yaml' file.
       No routes configured. Proxy will not be set up.
    

    This indicates that the plugin has been detected and no configuration file exists. Consequently, the plugin will create one with the following content:

      verbose: false
      routes: []
    
  5. Once completed, you can configure routes to your local service by modifying the configuration file. An example of such a configuration might appear as follows:

    verbose: true
    routes:
    - upstream: "http://localhost:8080" # The main URL where requests should be routed
      urlPrefix: "/platform/davis/analyzers" # All requests starting with this prefix are routed
      rewriteRule:
        inputPrefix: "/platform/" # The string "/platform/" in an routed request is replaced with...
        newPrefix: "/public/" # The string "/public/"

What does this example configuration do?

  • Firstly, it forwards all HTTP calls with the prefix "/platform/davis/analyzers" to http://localhost:8080. For example, if the Web App makes a call to http://localhost:3000/platform/davis/analyzers/v1/analyzers, this call is not forwarded to https://nrg77339.dev.apps.dynatracelabs.com/platform/davis/analyzers/v1/analyzers, assuming https://nrg77339.dev.apps.dynatracelabs.com is the configured "environmentUrl".
  • However, this configuration redirects the call to http://localhost:8080/public/davis/analyzers/v1/analyzers. This is due to the rewriteRule, which replaces anything starting with "/platform/" with "/public/". Hence, "platform/davis/analyzers/v1/analyzers" is transformed to "public/davis/analyzers/v1/analyzers" and the altered path is then forwarded to http://localhost:8080.
  • Note that the plugin also sets the "Dt-tenant" and "Authorization" HTTP headers. If there is no proper token available or cached for the Authorization header, the plugin will initiate an SSO call to obtain the appropriate token.

Readme

Keywords

Package Sidebar

Install

npm i simple-dt-dev-proxy-plugin

Weekly Downloads

1

Version

0.0.1

License

ISC

Unpacked Size

14.4 kB

Total Files

6

Last publish

Collaborators

  • hans989