cancel
Showing results for 
Search instead for 
Did you mean: 

Diferent URL service js with my App URL - XS Advanced

former_member664593
Participant
0 Kudos

Hi gurus.

I'm following this tutorial Developing with XS Advanced: Create a SAP HANA based client-server application. I don't created Calculation View.

When I run my xsodata service, I get this URL

https://cyuv0u1abc-services-js.YYY.ABC.hana.ondemand.com/index.xsjs

I tested above URL and working.

When I run my UI5 app I get this URL

https://9r4s2rw6hjabc-approuter.YYY.ABC.hana.ondemand.com/myapp-1.0.0/index2.html

Well, this two URLs hasn't the same domanin and I get code error 404 on console when I run my app.

Please, can you help me?

Thanks in advance.

Accepted Solutions (0)

Answers (1)

Answers (1)

mariusobert
Developer Advocate
Developer Advocate
0 Kudos

You end up with two different URLs because you created two app (aka microservices).

The first URL points to your server app that connected directly to the HANA DB and exposes the data. The second URL is the approuter (reverse proxy) that serves the static frontend files and redirects traffic to other microservices (like the first app).

A 404 error probably means you have a wrong configuration of the microservices or a bug in the code.

former_member664593
Participant
0 Kudos

Hi Marius.

This is my error on console.

I I think should be connect to https://cyuv0u1abc-services-js.YYY.ABC.hana.ondemand.com/index.xsjs and not this URL

mariusobert
Developer Advocate
Developer Advocate
0 Kudos

This looks right to me. The app router acts as a reverse proxy and forwards traffic to your "xsodata server". Either there is something going wrong during the proxying or the problem occurs in the xsodata service directly. I would recommend this post if you want to learn more about the Application Router.

If you think this is an issue with the tutorial itself, please use the "Provide Feedback" link in the tutorial. My guess is that this is a problem that happened when you were following the tutorial

former_member664593
Participant
0 Kudos

Hi Marcus.

I have a MTA project with three modules: APPUI5, HanaDB and Service JS.

mta.yaml

#-------BD HANA          
  - name: db
    type: hdb
    path: db
    requires:
      - name: hdi_db
#--------SERVICE JS      
  - name: my_services_js
    type: nodejs
    path: my_services_js
    requires:
      - name: db
      - name: hdi_db    
    provides:
      - name: my_services_js_api
        properties:
          url: ${default-url}
#--------UI5 APP      
  - name: MyAPP
    type: html5
    path: MyAPP
    build-parameters:
      builder: custom
      commands:
        - npm install
        - npm run build
      supported-platforms: []
      build-result: dist
    requires:
      - name: my_services_js_api
        group: destinations      
        properties:
          name: js-backend
          url: ~{url}

xs-app.json

{
  "welcomeFile": "/index.html",
  "authenticationMethod": "route",
  "logout": {
    "logoutEndpoint": "/do/logout"
  },
  "routes": [
    {
      "source": "^(.*)$",
      "target": "$1",
      "service": "html5-apps-repo-rt",
      "authenticationType": "xsuaa"
    },  	
    {
    	"source": "^/my_service.xsodata/.*$",
    	"destination": "js-backend"
    }
  ]
}

UI5 APP

<!DOCTYPE HTML><head><meta http-equiv="X-UA-Compatible" content="IE=Edge" /><title>DevXdemo</title><script src="https://sapui5.hana.ondemand.com/resources/sap-ui-core.js"id="sap-ui-bootstrap" data-sap-ui-libs="sap.ui.commons, sap.ui.table" data-sap-ui-theme="sap_bluecrystal"></script><script>

  var oModel =newsap.ui.model.odata.ODataModel("/my_service.xsodata", true);
  var oTable =newsap.ui.table.Table({title:"European Countries" });

  oTable.addColumn(newsap.ui.table.Column({ label:"Country Name", template: "codPaisSap" }));

  oTable.setModel(oModel); 
  oTable.bindRows("/MyEntity"); 
  oTable.placeAt("content");</script></head><body class='sapUiBody'><divid='content'></div></body></html>

I can't find error.

mariusobert
Developer Advocate
Developer Advocate
0 Kudos

In the screenshot you pasted earlier, the URL you try to access starts with "xsodata/.....xsodata" after the TLD. In your xs-app.json you match for "/my_service.xsodata". In other words, I don't think the approuter matches the URLs and therefore it doesn't redirect the traffic to the destination (aka service module).

Here's a reference for routes and URL matching.