2

It seems that I configured my approuter successfully:

Approuter

I gave a destination to my service in SCP Cockpit:

destination config in SCP Cockpit

And I maintained the destination in the xs-app.json:

    {
  "welcomeFile": "/webapp/index.html",
  "authenticationMethod": "route",
  "logout": {
    "logoutEndpoint": "/do/logout"
  },
  "routes": [
    {
      "source": "/destination",
      "target": "/",
      "destination": "service-destination"
    }
  ]
}

My question is now how can I access my service destination via approuter?

Shouldn't it be something like this: https://qfrrz1oj5pilzrw8zations-approuter.cfapps.eu10.hana.ondemand.com/webapp/index.html/destination

Accessing service via Approuter

...it returns Not found.

Any idea what I'm doing wrong here?

This is my mta.yaml (if relevant):

    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
Sander Wozniak
  • 650
  • 8
  • 27
RNLS0176
  • 115
  • 4
  • 13
  • 1
    Just a guess, but `../index.html/destination` does not look correct to me. Have you tried it without the `index.html` file name? – Florian Wilhelm May 08 '19 at 13:02
  • When trying https://qfrrz1oj5pilzrw8zations-approuter.cfapps.eu10.hana.ondemand.com/destination it looks somehow more promising since there seems to be a redirect. The URL changes to https://qfrrz1oj5pilzrw8zations-approuter.cfapps.eu10.hana.ondemand.com/odata/v2/ but the result is still "Not found". This odata/v2 suffix seems to be coming already from my destination: https://gfuowb4ettq19agtuthorizations-srv.cfapps.eu10.hana.ondemand.com/odata/v2/. But why is it not showing anything? – RNLS0176 May 08 '19 at 13:12
  • When I click the last link in your post, I get an HTML page now. That looks right to me. – Florian Wilhelm May 08 '19 at 13:16
  • The last link is my destination, which I want to reach via the approuter. So we are not there yet. – RNLS0176 May 08 '19 at 13:17
  • Oh, right, have not looked close enough. – Florian Wilhelm May 08 '19 at 13:18

1 Answers1

0

You have two hosts:

  • approuter
  • srv

The problem:

  • https://approuter/destination/ will proxy to https://srv/

    Notice the root path in the URL. You see the path segment of your destination is ignored by the approuter. Instead it looks for the routes[0].target declaration of your xs-app.json file.

The symptom:

The solution:

Adapt your xs-app.json to correctly refer the target endpoint path:

  "routes": [
    {
      "source": "/destination",
      "target": "/odata/v2",
      "destination": "service-destination"
    }

Follow up

Since your srv application statically references links to absolute path /odata/v2, you would either have to update each link in srv to use relative paths, or use "/odata/v2/" as your approuter route source to mirror the target. For the latter case you would miss out on the "/destination" path.

Alexander Dümont
  • 903
  • 1
  • 5
  • 9