How to easily consume nodejs-backend from html5 application with destinations?NodeJS on CloudFoundry : Application File Namevmc push of nodeJS report Application failed to startHow do deploy nodejs angular2 application in cloudfoundryHow to Read destination in manifest.yml in Spring boot application?Consuming OData from EclipseHow to add multiple destinations for a java application in cloud foundry?sap cloud platform List HTML5 Applications via API or CLI ToolRetrieve logged user information from cloud foundry web applicationHow to consume Destination from NodeJS in SAP Cloud Platformhow to access a different module in multi target application

Was Jacobi the first to notice the ambiguity in the partial derivatives notation? And did anyone object to his fix?

Why does FFmpeg choose 10+20+20 ms instead of an even 16 ms for 60 fps GIF images?

Sending a photo of my bank account card to the future employer

Do dragons smell of lilacs?

Create Array from list of indices/values

Intel 8080-based home computers

Is this artwork (used in a video game) real?

Why is Katakana not pronounced Katagana?

Why do so many pure math PhD students drop out or leave academia, compared to applied mathematics PhDs?

Why is Google approaching my VPS machine?

What does it actually mean to have two time dimensions?

Why doesn't philosophy have higher standards for its arguments?

Is it legal for a supermarket to refuse to sell an adult beer if an adult with them doesn’t have their ID?

Which GPUs to get for Mathematical Optimization (if any...)?

What were the problems on the Apollo 11 lunar module?

Can a Resident Assistant be told to ignore a lawful order?'

What are "full piece" and "half piece" in chess?

Improve quality of image bars

Alphanumeric Line and Curve Counting

How to have a continuous player experience in a setting that's likely to favor TPKs?

What are the first usages of "thong" as a wearable item of clothing, both on the feet and on the waist?

How fast does a character need to move to be effectively invisible?

Vienna To Graz By Rail

What happens if there is no space for entry stamp in the passport for US visa?



How to easily consume nodejs-backend from html5 application with destinations?


NodeJS on CloudFoundry : Application File Namevmc push of nodeJS report Application failed to startHow do deploy nodejs angular2 application in cloudfoundryHow to Read destination in manifest.yml in Spring boot application?Consuming OData from EclipseHow to add multiple destinations for a java application in cloud foundry?sap cloud platform List HTML5 Applications via API or CLI ToolRetrieve logged user information from cloud foundry web applicationHow to consume Destination from NodeJS in SAP Cloud Platformhow to access a different module in multi target application






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I want to "connect" the html5 module with the nodejs backend, so that the frontend can access the backend for db logic. I found, that I have to create a destination in scp and write it in the mta.yaml and xs-app.js file for the approuter. Unfortunately it works not properly as there's the error: "Not Found".



The html5 frontend makes simply an ajax request.
The nodjs backend recieves requests by express and operates with db.



I created a destination in scp which is called backendApi. The url is the one of the node_backend.



A code snippet from the mta.yaml file:



name: node_backend
type: nodejs
path: node_backend
requires:
- name: mongodb-nemo-t01-service
- name: cf_elb_postgres
provides:
- name: node_backend_api
properties:
url: '$default-url'

- name: cfElbTimeline
type: html5
path: cfElbTimeline
parameters:
disk-quota: 500M
memory: 500M
build-parameters:
builder: grunt
requires:
- name: node_backend_api
group: destinations
properties:
name: backendApi
url: '~url'
forwardAuthToken: true


My xs-app.js file:




"welcomeFile": "/index.html",
"authenticationMethod": "route",
"logout":
"logoutEndpoint": "/do/logout"
,
"routes": [
"source": "^(.*)$",
"target": "$1",
"service": "html5-apps-repo-rt",
"authenticationType": "xsuaa"
,
"source": "^(.*)$",
"target": "$1",
"destination": "backendApi",
"httpMethods": ["GET", "POST"],
"authenticationType": "none"
]



It already worked once to access the backend via the frontend, but there was a problem with the html5 application repository, so the view was not visible. So I changed it, but can not get back to the point, when i could access the backend via the approuter url. Maybe there's something wrong with the route's regex?



Can anyone check my code or can explain, how it should work?










share|improve this question






























    1















    I want to "connect" the html5 module with the nodejs backend, so that the frontend can access the backend for db logic. I found, that I have to create a destination in scp and write it in the mta.yaml and xs-app.js file for the approuter. Unfortunately it works not properly as there's the error: "Not Found".



    The html5 frontend makes simply an ajax request.
    The nodjs backend recieves requests by express and operates with db.



    I created a destination in scp which is called backendApi. The url is the one of the node_backend.



    A code snippet from the mta.yaml file:



    name: node_backend
    type: nodejs
    path: node_backend
    requires:
    - name: mongodb-nemo-t01-service
    - name: cf_elb_postgres
    provides:
    - name: node_backend_api
    properties:
    url: '$default-url'

    - name: cfElbTimeline
    type: html5
    path: cfElbTimeline
    parameters:
    disk-quota: 500M
    memory: 500M
    build-parameters:
    builder: grunt
    requires:
    - name: node_backend_api
    group: destinations
    properties:
    name: backendApi
    url: '~url'
    forwardAuthToken: true


    My xs-app.js file:




    "welcomeFile": "/index.html",
    "authenticationMethod": "route",
    "logout":
    "logoutEndpoint": "/do/logout"
    ,
    "routes": [
    "source": "^(.*)$",
    "target": "$1",
    "service": "html5-apps-repo-rt",
    "authenticationType": "xsuaa"
    ,
    "source": "^(.*)$",
    "target": "$1",
    "destination": "backendApi",
    "httpMethods": ["GET", "POST"],
    "authenticationType": "none"
    ]



    It already worked once to access the backend via the frontend, but there was a problem with the html5 application repository, so the view was not visible. So I changed it, but can not get back to the point, when i could access the backend via the approuter url. Maybe there's something wrong with the route's regex?



    Can anyone check my code or can explain, how it should work?










    share|improve this question


























      1












      1








      1








      I want to "connect" the html5 module with the nodejs backend, so that the frontend can access the backend for db logic. I found, that I have to create a destination in scp and write it in the mta.yaml and xs-app.js file for the approuter. Unfortunately it works not properly as there's the error: "Not Found".



      The html5 frontend makes simply an ajax request.
      The nodjs backend recieves requests by express and operates with db.



      I created a destination in scp which is called backendApi. The url is the one of the node_backend.



      A code snippet from the mta.yaml file:



      name: node_backend
      type: nodejs
      path: node_backend
      requires:
      - name: mongodb-nemo-t01-service
      - name: cf_elb_postgres
      provides:
      - name: node_backend_api
      properties:
      url: '$default-url'

      - name: cfElbTimeline
      type: html5
      path: cfElbTimeline
      parameters:
      disk-quota: 500M
      memory: 500M
      build-parameters:
      builder: grunt
      requires:
      - name: node_backend_api
      group: destinations
      properties:
      name: backendApi
      url: '~url'
      forwardAuthToken: true


      My xs-app.js file:




      "welcomeFile": "/index.html",
      "authenticationMethod": "route",
      "logout":
      "logoutEndpoint": "/do/logout"
      ,
      "routes": [
      "source": "^(.*)$",
      "target": "$1",
      "service": "html5-apps-repo-rt",
      "authenticationType": "xsuaa"
      ,
      "source": "^(.*)$",
      "target": "$1",
      "destination": "backendApi",
      "httpMethods": ["GET", "POST"],
      "authenticationType": "none"
      ]



      It already worked once to access the backend via the frontend, but there was a problem with the html5 application repository, so the view was not visible. So I changed it, but can not get back to the point, when i could access the backend via the approuter url. Maybe there's something wrong with the route's regex?



      Can anyone check my code or can explain, how it should work?










      share|improve this question
















      I want to "connect" the html5 module with the nodejs backend, so that the frontend can access the backend for db logic. I found, that I have to create a destination in scp and write it in the mta.yaml and xs-app.js file for the approuter. Unfortunately it works not properly as there's the error: "Not Found".



      The html5 frontend makes simply an ajax request.
      The nodjs backend recieves requests by express and operates with db.



      I created a destination in scp which is called backendApi. The url is the one of the node_backend.



      A code snippet from the mta.yaml file:



      name: node_backend
      type: nodejs
      path: node_backend
      requires:
      - name: mongodb-nemo-t01-service
      - name: cf_elb_postgres
      provides:
      - name: node_backend_api
      properties:
      url: '$default-url'

      - name: cfElbTimeline
      type: html5
      path: cfElbTimeline
      parameters:
      disk-quota: 500M
      memory: 500M
      build-parameters:
      builder: grunt
      requires:
      - name: node_backend_api
      group: destinations
      properties:
      name: backendApi
      url: '~url'
      forwardAuthToken: true


      My xs-app.js file:




      "welcomeFile": "/index.html",
      "authenticationMethod": "route",
      "logout":
      "logoutEndpoint": "/do/logout"
      ,
      "routes": [
      "source": "^(.*)$",
      "target": "$1",
      "service": "html5-apps-repo-rt",
      "authenticationType": "xsuaa"
      ,
      "source": "^(.*)$",
      "target": "$1",
      "destination": "backendApi",
      "httpMethods": ["GET", "POST"],
      "authenticationType": "none"
      ]



      It already worked once to access the backend via the frontend, but there was a problem with the html5 application repository, so the view was not visible. So I changed it, but can not get back to the point, when i could access the backend via the approuter url. Maybe there's something wrong with the route's regex?



      Can anyone check my code or can explain, how it should work?







      cloudfoundry sap-web-ide multitargeting sap-cloud-platform






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 30 at 7:49







      Paigeola

















      asked Mar 26 at 9:01









      PaigeolaPaigeola

      228 bronze badges




      228 bronze badges






















          1 Answer
          1






          active

          oldest

          votes


















          1














          The routes defined in your xs-app.json are considered in the order of entry when it comes to matching against the same pattern. Meaning, any request that you think is possibly made to the API is served by the first route: i.e; HTML5 repo service which only contains static files.



          Also it's a good idea to differentiate the routes to avoid confusion. You can differentiate the API route by adding a route prefix or have a different pattern altogether.



          For example:




          "welcomeFile": "/index.html",
          "authenticationMethod": "route",
          "logout":
          "logoutEndpoint": "/do/logout"
          ,
          "routes": [
          "source": "^(.*)$",
          "target": "$1",
          "service": "html5-apps-repo-rt",
          "authenticationType": "xsuaa"
          ,
          "source": "^/api/(.*)$",
          "target": "$1",
          "destination": "backendApi",
          "httpMethods": ["GET", "POST"],
          "authenticationType": "none"
          ]



          You'd then be able to access the destination from the approuter like so :



          https://<approuter_url>/<app_name-version>/api/whatever.xsodata





          share|improve this answer






















            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55353211%2fhow-to-easily-consume-nodejs-backend-from-html5-application-with-destinations%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            The routes defined in your xs-app.json are considered in the order of entry when it comes to matching against the same pattern. Meaning, any request that you think is possibly made to the API is served by the first route: i.e; HTML5 repo service which only contains static files.



            Also it's a good idea to differentiate the routes to avoid confusion. You can differentiate the API route by adding a route prefix or have a different pattern altogether.



            For example:




            "welcomeFile": "/index.html",
            "authenticationMethod": "route",
            "logout":
            "logoutEndpoint": "/do/logout"
            ,
            "routes": [
            "source": "^(.*)$",
            "target": "$1",
            "service": "html5-apps-repo-rt",
            "authenticationType": "xsuaa"
            ,
            "source": "^/api/(.*)$",
            "target": "$1",
            "destination": "backendApi",
            "httpMethods": ["GET", "POST"],
            "authenticationType": "none"
            ]



            You'd then be able to access the destination from the approuter like so :



            https://<approuter_url>/<app_name-version>/api/whatever.xsodata





            share|improve this answer



























              1














              The routes defined in your xs-app.json are considered in the order of entry when it comes to matching against the same pattern. Meaning, any request that you think is possibly made to the API is served by the first route: i.e; HTML5 repo service which only contains static files.



              Also it's a good idea to differentiate the routes to avoid confusion. You can differentiate the API route by adding a route prefix or have a different pattern altogether.



              For example:




              "welcomeFile": "/index.html",
              "authenticationMethod": "route",
              "logout":
              "logoutEndpoint": "/do/logout"
              ,
              "routes": [
              "source": "^(.*)$",
              "target": "$1",
              "service": "html5-apps-repo-rt",
              "authenticationType": "xsuaa"
              ,
              "source": "^/api/(.*)$",
              "target": "$1",
              "destination": "backendApi",
              "httpMethods": ["GET", "POST"],
              "authenticationType": "none"
              ]



              You'd then be able to access the destination from the approuter like so :



              https://<approuter_url>/<app_name-version>/api/whatever.xsodata





              share|improve this answer

























                1












                1








                1







                The routes defined in your xs-app.json are considered in the order of entry when it comes to matching against the same pattern. Meaning, any request that you think is possibly made to the API is served by the first route: i.e; HTML5 repo service which only contains static files.



                Also it's a good idea to differentiate the routes to avoid confusion. You can differentiate the API route by adding a route prefix or have a different pattern altogether.



                For example:




                "welcomeFile": "/index.html",
                "authenticationMethod": "route",
                "logout":
                "logoutEndpoint": "/do/logout"
                ,
                "routes": [
                "source": "^(.*)$",
                "target": "$1",
                "service": "html5-apps-repo-rt",
                "authenticationType": "xsuaa"
                ,
                "source": "^/api/(.*)$",
                "target": "$1",
                "destination": "backendApi",
                "httpMethods": ["GET", "POST"],
                "authenticationType": "none"
                ]



                You'd then be able to access the destination from the approuter like so :



                https://<approuter_url>/<app_name-version>/api/whatever.xsodata





                share|improve this answer













                The routes defined in your xs-app.json are considered in the order of entry when it comes to matching against the same pattern. Meaning, any request that you think is possibly made to the API is served by the first route: i.e; HTML5 repo service which only contains static files.



                Also it's a good idea to differentiate the routes to avoid confusion. You can differentiate the API route by adding a route prefix or have a different pattern altogether.



                For example:




                "welcomeFile": "/index.html",
                "authenticationMethod": "route",
                "logout":
                "logoutEndpoint": "/do/logout"
                ,
                "routes": [
                "source": "^(.*)$",
                "target": "$1",
                "service": "html5-apps-repo-rt",
                "authenticationType": "xsuaa"
                ,
                "source": "^/api/(.*)$",
                "target": "$1",
                "destination": "backendApi",
                "httpMethods": ["GET", "POST"],
                "authenticationType": "none"
                ]



                You'd then be able to access the destination from the approuter like so :



                https://<approuter_url>/<app_name-version>/api/whatever.xsodata






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered May 12 at 22:13









                goodboigoodboi

                7452 silver badges9 bronze badges




                7452 silver badges9 bronze badges


















                    Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







                    Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55353211%2fhow-to-easily-consume-nodejs-backend-from-html5-application-with-destinations%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                    Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

                    Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript