cancel
Showing results for 
Search instead for 
Did you mean: 

Enable PWA for ui5 in CF BTP

former_member724290
Participant

Hi All.

I try to enable PWA for my ui5 application.

I have problem with manifest tag in index.html file. Service worker sarts and works fine but manifest file is not loaded.

Question is: how to enable PWA for sap ui5 application in BTP (not openUI5)?

See screens below:

Accepted Solutions (1)

Accepted Solutions (1)

Ivan-Mirisola
Product and Topic Expert
Product and Topic Expert

Hi and_andrey,

You have an authorization error (http 401 means you are trying to retrieve a protected resource from your web application). If you are using SAP's AppRouter to implement security on your app, check the file xs-app.json conatins a route to "/nosecure" with authentication = 'none'. It should look like so:

{
  "authenticationMethod": "route",
  "routes": [
    {
      "source": "/nosecure/(.*)",
      "target": "/nosecure/$1",
      "localDir": "my-static-resources"
      "authenticationType": "none",
      "csrfProtection": false
    },
    {
      "source": "^/(.*)$",
      "target": "/web/$1",
      "authenticationType": "xsuaa",
      "csrfProtection": true
     }
  ]
}<br>

Otherwise, please share that file along with mta.yaml and xs-security.json so we are able to give you more pointers.

Best regards,
Ivan

former_member724290
Participant
0 Kudos

Hi Ivan.

Thank you for answer.
Kindly see screens below. Please, take a look at masks in xs-app.json.
Also, I attached log from BTP.

Error from BTP:

GET request to /341ae989-f0ea-4ad7-b005-ee202fcd7b63.testmanifest.testmanifest-0.0.1 completed with status 500 xs-app.json/routes/0: Format validation failed (Route does not have a destination nor a localDir nor a service)

As result Error 500 in response.

Thx.

Ivan-Mirisola
Product and Topic Expert
Product and Topic Expert

Hi and_andrey,

Sorry, my fault - I accidentally deleted a piece of configuration for that specific route. You should be using either a service, a local resource or a destination. On my particular example, the nonsecure reffered to a localDir which is supposed to be on the file system of the AppRouter itself.

Please check the options here:

https://www.npmjs.com/package/@sap/approuter

Best regards,
Ivan

former_member724290
Participant
0 Kudos

Hi Ivan.

Many thanks. Problem is resolved. I used "service": "html5-apps-repo-rt" and this helped me.

Is it a proper parametr for my case or I should use other one (localDir or Destination)? I don't shure about this.

Thank you!

Ivan-Mirisola
Product and Topic Expert
Product and Topic Expert

Hi and_andrey,

I understand that those resources are just the json files that are required by your application when there is no user logged on yet.
However, if you do not have that situation, the recommendation is that you have a user logon to the application before you deliver such resources to the front-end.

I suppose you can use the service parameter without any issues - but I am not a PWA expert so I cannot attest that it is safe to serve such resources without any authentication.

Since such resources are found under the html5 repository service, it simply means that there is no authentication required for anyone to load resources from that path (nosecure) which are served by the html5 repository.

Best regards,
Ivan

Answers (0)