0.0.1 • Published 2 years ago
simple-dt-dev-proxy-plugin v0.0.1
Overview
A simple extension for Dynatrace development tools, enabling the routing of certain platform calls to locally running services.
How to use it?
- Checkout this project.
- Build the project using the following command:
npm run build 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: {} }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: []- 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 tohttp://localhost:3000/platform/davis/analyzers/v1/analyzers, this call is not forwarded tohttps://nrg77339.dev.apps.dynatracelabs.com/platform/davis/analyzers/v1/analyzers, assuminghttps://nrg77339.dev.apps.dynatracelabs.comis 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 tohttp://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.
0.0.1
2 years ago