Giter Site home page Giter Site logo

Comments (4)

saphanaacademy avatar saphanaacademy commented on July 30, 2024

G'day Jason,

Thanks for using the generator and asking the question.

Have you seen this tutorial which covers local development?

The recommended approach is to build and deploy the project to Cloud Foundry, then use DefaultEnv to create a local default-env.json file, set CAP to use the "production" profile with cmd export CDS_ENV=production then use cds watch or cds run or all-in-one CDS_ENV=production cds watch

Best way to access the UI is to use the auto-generated links in the "Web Applications" section of http://localhost:4004 and authenticate using one of the local test users eg: joe defined in package.json.

In most cases this should suffice.

Thanks.

from generator-saphanaacademy-cap.

js1972 avatar js1972 commented on July 30, 2024

Hi, I have watched those local development videos you linked but the app is structured differently. Apps generated by this yeoman generator have this XS-app.json:

{
    "welcomeFile": "index.html",
    "authenticationMethod": "route",
    "routes": [
        {
            "source": "^/catalog/(.*)$",
            "csrfProtection": false,
            "authenticationType": "xsuaa",
            "destination": "jasonhanaapp-srv"
        },
        {
            "source": "^/(.*)$",
            "authenticationType": "xsuaa",
            "service": "html5-apps-repo-rt"
        }
    ]
}

Note the destination mentioned above for the catalog service!

So in my app/default-env.json I add this to match:

"destinations": "[ {\n  \"forwardAuthToken\" : true,\n  \"name\" : \"jasonhanaapp-srv\",\n  \"url\" : \"http://localhost:5001\"\n} ]",

Now I start the local service with cds watch --production and this connects to the real hana db.
Then I start the approuter in /app with npm start.
When I goto the approuter I get the proper xsuaa redirect which is all good. Note that I need to adjust the path slightly and remove the "resources" part like so: http://localhost:5000/html5/index.html. If doing pure local development (sqlite) then the path from cds watch is: http://localhost:4004/resources/html5/index.html.

This shows the index page well. But when I click any links that call into the CAP SRV it fails with "not found" error.

So the difference in architecture here is that in the local development YouTube videos from Philip there is no destinations created and the MTA just refers to srv-api. Whereas with this generator there seems to be a bunch of destinations created and one of them: jasonhanaapp-srv is referenced in the XS-app.json as copied above.

The approuter when running locally issues this error when you hit a catalog url:

GET request to //html5/catalog/ completed with status 404 ENOENT: no such file or directory, stat '/Users/I540401/dev/jasonhanaapp/app/resources/html5/catalog/index.html'#

So I'm wondering - what is it about the structure of this app that means this won't work? I can see its something to do with th destinations...

from generator-saphanaacademy-cap.

saphanaacademy avatar saphanaacademy commented on July 30, 2024

Hi,
Are you using SAP Business Application Studio or pure local development such as with Visual Studio Code?
It looks like the project is using the HTML5 repository and its own project app router rather than the managed app router. Is that correct?
Would you be able to share the entire project or the answers to the prompts when using the generator - so we can try to reproduce the issue?
Thanks.

from generator-saphanaacademy-cap.

js1972 avatar js1972 commented on July 30, 2024

I have solved the issue and it was mainly just my lack of understanding. I was trying to run approuter locally which was causing the above issue.

By simply running cf de jasonhanaapp-srv to download the HANA Cloud credentials from cloud foundry into a default-env.json file it all worked using HANA Cloud as the DB instead of SQLite. I could run the app with CDS_ENV=production cds watch.

Thanks for your help.

from generator-saphanaacademy-cap.

Related Issues (5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.