看来我已经成功配置了我的approuter:
我在SCP驾驶舱中指定了目的地:
destination config in SCP Cockpit
然后我将目的地保存在xs-app.json中:
{
"welcomeFile": "/webapp/index.html",
"authenticationMethod": "route",
"logout": {
"logoutEndpoint": "/do/logout"
},
"routes": [
{
"source": "/destination",
"target": "/",
"destination": "service-destination"
}
]
}
我的问题是,现在如何通过approuter访问服务目的地?
Accessing service via Approuter
...返回未找到。
知道我在做什么错吗?
这是我的mta.yaml(如果有):
ID: oDataAuthorizations
_schema-version: '2.1'
version: 0.0.1
modules:
- name: oDataAuthorizations-db
type: hdb
path: db
parameters:
memory: 256M
disk-quota: 256M
requires:
- name: oDataAuthorizations-hdi-container
- name: oDataAuthorizations-srv
type: java
path: srv
parameters:
memory: 1024M
provides:
- name: srv_api
properties:
url: '${default-url}'
requires:
- name: oDataAuthorizations-hdi-container
properties:
JBP_CONFIG_RESOURCE_CONFIGURATION: '[tomcat/webapps/ROOT/META-INF/context.xml: {"service_name_for_DefaultDB" : "~{hdi-container-name}"}]'
- name: xsuaa-auto
- name: approuter
type: html5
path: approuter
parameters:
disk-quota: 256M
memory: 256M
build-parameters:
builder: grunt
requires:
- name: dest_oDataAuthorizations
- name: srv_api
group: destinations
properties:
name: service-destination
url: '~{url}'
forwardAuthToken: true
- name: xsuaa-auto
resources:
- name: oDataAuthorizations-hdi-container
type: com.sap.xs.hdi-container
properties:
hdi-container-name: '${service-name}'
- name: xsuaa-auto
type: org.cloudfoundry.managed-service
parameters:
path: ./cds-security.json
service-plan: application
service: xsuaa
config:
xsappname: xsuaa-auto
tenant-mode: dedicated
- name: dest_oDataAuthorizations
parameters:
service-plan: lite
service: destination
type: org.cloudfoundry.managed-service
答案 0 :(得分:3)
您有两个主持人:
问题:
https://approuter/destination/将代理到https://srv/
注意URL中的根路径。您会看到approuter忽略了目标的路径段。相反,它会寻找routes[0].target
文件的xs-app.json
声明。
症状:
/odata/v2
。 https://approuter/destination/ xs-app.json
中未定义路由解决方案:
调整您的xs-app.json
以正确引用目标端点路径:
"routes": [
{
"source": "/destination",
"target": "/odata/v2",
"destination": "service-destination"
}
关注
由于您的 srv 应用程序静态引用了指向绝对路径/odata/v2
的链接,因此您将不得不更新 srv 中的每个链接以使用相对路径或使用"/odata/v2/"
作为您的approuter路由source
来镜像目标。对于后一种情况,您会错过"/destination"
路径。