{"id":18888,"library":"ui5-middleware-route-proxy","title":"ui5-middleware-route-proxy","description":"A middleware for the SAP UI5 tooling's ui5-server that enables route-based proxying of HTTP requests to backend servers. Version 1.0.10 is the current stable release, with automated publishes via GitHub Actions. It supports flexible configuration via ui5.yaml, including authentication (basic auth or custom Authorization header), path replacement, and changeOrigin option from http-proxy. It integrates with .env files for secrets, and is commonly used in UI5 development to proxy OData or other backend services. Compared to alternatives like ui5-middleware-simpleproxy, it offers per-route configuration and auth header customization.","status":"active","version":"1.0.10","language":"javascript","source_language":"en","source_url":"https://github.com/lemaiwo/ui5-middleware-route-proxy","tags":["javascript"],"install":[{"cmd":"npm install ui5-middleware-route-proxy","lang":"bash","label":"npm"},{"cmd":"yarn add ui5-middleware-route-proxy","lang":"bash","label":"yarn"},{"cmd":"pnpm add ui5-middleware-route-proxy","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core proxy functionality; used to forward requests to target servers.","package":"http-proxy","optional":false},{"reason":"Loads environment variables from .env file for configuration.","package":"dotenv","optional":false}],"imports":[{"note":"The package is used as a UI5 tooling middleware, not imported in application code. It is listed in package.json under ui5.dependencies and configured in ui5.yaml.","wrong":"const proxy = require('ui5-middleware-route-proxy'); // not used directly in code","symbol":"ui5-middleware-route-proxy","correct":"No JavaScript import; configured in ui5.yaml under server.customMiddleware"}],"quickstart":{"code":"// .env file\nPROXY_TARGET=https://mybackend.example.com\nPROXY_USERNAME=myuser\nPROXY_PASSWORD=mypassword\n\n// ui5.yaml\nserver:\n  customMiddleware:\n  - name: ui5-middleware-route-proxy\n    afterMiddleware: compression\n    configuration:\n      debug: true\n      /sap:\n        target: PROXY_TARGET\n        auth:\n          user: PROXY_USERNAME\n          pass: PROXY_PASSWORD\n        replacePath: true\n        changeOrigin: true\n\n// package.json (devDependencies)\n{\n  \"devDependencies\": {\n    \"ui5-middleware-route-proxy\": \"*\"\n  },\n  \"ui5\": {\n    \"dependencies\": [\n      \"ui5-middleware-route-proxy\"\n    ]\n  }\n}\n\n// Install dependencies\nnpm install --save-dev ui5-middleware-route-proxy dotenv\n\n// Start UI5 server\nui5 serve --config ui5.yaml","lang":"yaml","description":"Shows minimal configuration to proxy /sap requests to a backend with authentication and path replacement."},"warnings":[{"fix":"Add the package to 'ui5.dependencies' array in package.json, and also include it in 'devDependencies'.","message":"Package must be listed in both devDependencies and ui5.dependencies in package.json, otherwise UI5 tooling will not load it.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure 'compression' middleware is enabled in your UI5 project, or adjust 'afterMiddleware' to an existing middleware like 'serveIndex'.","message":"The 'afterMiddleware' property must be set correctly to avoid middleware execution order issues. Typically 'compression' is used, but if compression middleware is not present, the server may fail.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Either use 'header' or 'user'/'pass', not both in the same path configuration. If using 'header', ensure it's a valid Authorization header value.","message":"If the auth object contains a 'header' property, 'user' and 'pass' are ignored. Misconfiguration leads to unexpected authentication behavior.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Always start the route key with '/' (e.g., '/sap', '/odata').","message":"The route key (e.g., '/sap') must include a leading slash. Omitting it will cause the route to not match.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Double-check .env variable names and ensure they match the values in ui5.yaml. Enclose in quotes if necessary.","message":"When using .env variables, the variable name must be exactly as in .env file. Any mismatch results in the literal string being used.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Explicitly set 'replacePath' to a string path if you need custom replacement, or set to true for current behavior.","message":"The 'replacePath' option when set to true removes the route prefix from the forwarded path. This behavior may change in future versions.","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run 'npm install --save-dev ui5-middleware-route-proxy' and add the package to 'ui5.dependencies' array in package.json.","cause":"Package not installed or not listed in ui5.dependencies in package.json.","error":"Error: Cannot find module 'ui5-middleware-route-proxy'"},{"fix":"Create a .env file in the project root, or install dotenv: 'npm install dotenv'.","cause":"Missing .env file in project root, or dotenv not installed.","error":"ENOENT: no such file or directory, open '.env'"},{"fix":"Ensure 'afterMiddleware' is at the same level as 'name' and 'configuration', not inside 'configuration'.","cause":"The 'afterMiddleware' property is placed incorrectly in the configuration object.","error":"Invalid configuration: middleware 'ui5-middleware-route-proxy' has unknown property 'afterMiddleware'"},{"fix":"Check ui5.yaml: each route must be a key under 'configuration' with a 'target' property. Ensure proper YAML indentation.","cause":"Misconfigured route object; likely a missing route key or incorrect indentation in YAML.","error":"TypeError: Cannot read property 'target' of undefined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}