I'm trying to use the fiori-tools-proxy to proxy every request that starts with a certain string and I want to replace that starting string with another one.
I'll try to write down an example: every request starting with /DEST should redirect to /sap and of course adding the first part of the URL. This is my ui5.yaml file:
specVersion: "3.1"
metadata:
name: testapp
type: application
server:
customMiddleware:
- name: fiori-tools-proxy
afterMiddleware: compression
configuration:
ignoreCertError: true
ui5:
path:
- /resources
- /test-resources
url: https://ui5.sap.com
backend:
- path: /DEST
url: https://myurl:8001
client: "500"
- name: fiori-tools-appreload
afterMiddleware: compression
configuration:
port: 35729
path: webapp
delay: 300
- name: ui5-tooling-transpile-middleware
afterMiddleware: compression
configuration:
debug: true
transformModulesToUI5:
overridesToOverride: true
excludePatterns:
- /Component-preload.js
- name: fiori-tools-preview
afterMiddleware: fiori-tools-appreload
configuration:
component: testapp
ui5Theme: sap_horizon
- name: ui5-tooling-modules-middleware
afterMiddleware: compression
builder:
customTasks:
- name: ui5-tooling-transpile-task
afterTask: replaceVersion
configuration:
debug: true
transformModulesToUI5:
overridesToOverride: true
And here is where I write the proxy
backend:
- path: /DEST
url: https://myurl:8001
client: "500"
But writing it like this proxy every call that starts with /DEST
without replacing it with /sap
so for example /DEST/opu/odata/sap/...
will be proxied to https://myurl:8001/DEST/opu/odata/sap/...
but what I want to achieve is to proxy it to https://myurl:8001/sap/opu/odata/sap/...
One other thing before someone responds to this post, for what I'm trying to achieve with this project I cannot just change /DEST with /sup. I know it's the easy way out, but I cannot do that.
I have read the @sap/ux-ui5-tooling docs but didn't find examples that show a use case like mine.
The docs you linked say that the backend proxy is based on @sap-ux/backend-proxy-middleware
The docs of this package have an example on how to change the path to which a request is proxied.
configuration:
backend:
path: /DEST
pathReplace: /sap