UI5 Simple Proxy Middleware
raw JSON →ui5-middleware-simpleproxy is a middleware for the UI5 Tooling ecosystem, specifically designed to integrate with `@ui5/server`. It provides a simple HTTP and WebSocket proxying capability for UI5 applications during development. Currently at stable version 3.7.0, it follows the UI5 CLI's major versioning for compatibility, requiring `@ui5/cli@3.0.0` or higher for its 3.x releases. The package allows developers to configure a base URI, handle SSL certificates, manage HTTP headers and query parameters, and define exclusion patterns directly within their `ui5.yaml` file. A key differentiator is its straightforward configuration via YAML and environment variables, providing a flexible solution for connecting local UI5 development servers to backend services, including support for basic authentication and optional ETag removal. It's a fundamental tool for managing backend communication in UI5 local development setups.
Common errors
error Error: unable to verify the first certificate ↓
ui5.yaml configuration, set strictSSL: false under the middleware's configuration block to disable certificate validation. error Custom middleware 'ui5-middleware-simpleproxy' not found ↓
npm install ui5-middleware-simpleproxy --save-dev and verify that your @ui5/cli version meets the minimum requirement (e.g., ^3.0.0 for middleware v3). error Missing mandatory configuration parameter 'baseUri' ↓
baseUri property to the configuration section of ui5-middleware-simpleproxy in your ui5.yaml with the target backend URL: configuration:\n baseUri: "https://your.backend.service". Warnings
breaking Major version 3 of `ui5-middleware-simpleproxy` requires `@ui5/cli` version 3.0.0 or higher. Using it with older versions of `@ui5/cli` will lead to compatibility issues or prevent the middleware from loading. ↓
gotcha The `strictSSL` configuration option defaults to `true`. If your `baseUri` points to an HTTPS service with a self-signed or untrusted SSL certificate, you will encounter `Error: unable to verify the first certificate`. ↓
gotcha Configuration parameters defined in `ui5.yaml` can be overridden by corresponding environment variables (e.g., `UI5_MIDDLEWARE_SIMPLE_PROXY_BASEURI` for `baseUri`) or values parsed from a `.env` file in the project root. ↓
gotcha The `mountPath` configured for the middleware (e.g., `/odata`) is separate from the `baseUri`. The `baseUri` should always be the complete, absolute URL of the backend service and is used as-is, without considering the `mountPath`. ↓
Install
npm install ui5-middleware-simpleproxy yarn add ui5-middleware-simpleproxy pnpm add ui5-middleware-simpleproxy Imports
- ui5-middleware-simpleproxy wrong
import { ui5MiddlewareSimpleproxy } from 'ui5-middleware-simpleproxy';correctserver: customMiddleware: - name: ui5-middleware-simpleproxy - baseUri wrong
configuration: uri: "https://services.odata.org"correctconfiguration: baseUri: "https://services.odata.org" - strictSSL wrong
configuration: ignoreSSL: truecorrectconfiguration: strictSSL: false
Quickstart
// Step 1: Install the middleware as a development dependency.
// npm install ui5-middleware-simpleproxy --save-dev
// Step 2: Configure the middleware in your UI5 project's `ui5.yaml` file.
// This is an example of the YAML configuration required, shown here commented out
// as it is not direct JavaScript code but rather a configuration file entry.
/*
# ui5.yaml content:
server:
customMiddleware:
- name: ui5-middleware-simpleproxy
# The middleware will process requests that start with this path
mountPath: /odata
# Specify to run this middleware after the 'compression' middleware
afterMiddleware: compression
configuration:
# The target URI to proxy requests to
baseUri: "https://services.odata.org"
# Optional: Username for Basic Authentication
username: "myUsername"
# Optional: Password for Basic Authentication
password: "myPassword"
# Optional: Custom HTTP headers to be sent with the proxied request
httpHeaders:
Any-Header: AnyHeaderValue
# Optional: Query parameters to be appended to the proxied request
query:
sap-client: '206'
# Optional: Array of glob patterns for paths to exclude from proxying
excludePatterns:
- "/local/**"
# Optional: Enable WebSocket proxying (experimental, defaults to false)
enableWebSocket: false
# Optional: Set to 'false' to ignore strict SSL checks (default is true)
strictSSL: false
*/
// Note: Configuration values in ui5.yaml can be overridden by environment variables.
// Example using process.env (for demonstration, actual usage would be shell variables):
// process.env.UI5_MIDDLEWARE_SIMPLE_PROXY_BASEURI = 'https://some.other.backend.com/sap';
// process.env.UI5_MIDDLEWARE_SIMPLE_PROXY_STRICT_SSL = 'false';
// After configuration, run your UI5 application with `ui5 serve` to activate the proxy.