Best Practices - meta-d/sap-fiori-templates GitHub Wiki

🏆 Best Practices

Access BSP App via Subpath

After deploying the application to BSP, it is unable to directly access its web pages through subpaths, instead displaying an error message: "File NOT found!". This error indicates that when attempting to access the webpage directly through a subpath (or subdirectory), the system cannot locate the corresponding file.

The issue lies in the handling logic of SAP NetWeaver Server for application requests, where it fails to recognize and process subpaths. To resolve this problem, a method is to add a redirection rule in the code of the ui5 repository runtime class, redirecting the subpaths to the root path of the BSP application.

Modify method METHOD /ui5/if_ui5_rep_rt~get_file in class /UI5/CL_UI5_REP_RT, add mapping any subpaths not in mapper to index.html path.

  IF ls_path_mapping IS NOT INITIAL.
    lv_path = ls_path_mapping-internal_rep_path.
    lv_internal_target_rep = ls_path_mapping-internal_rep.
  ELSE.
    IF iv_skip_miss_mapping_fallback = abap_false.
     "fallback logic (no name shortening, internal rep determined by file extension)
     "TODO Clarify why is this needed? This would mean the repo is inconsistent
+    "fallback any folder not in mapper to index.html
+      SPLIT iv_path AT '/' INTO TABLE DATA(lt_strs).
+      DATA(lv_last_part) = lt_strs[ lines( lt_strs ) ].
+      IF lv_last_part NS '.'.
+        lv_path = `index.html`.
+        lv_internal_target_rep = c_internal_target_rep_bsp.
+      ELSE.
        lv_path = iv_path.
        lv_internal_target_rep = /ui5/cl_ui5_rep_utility=>determine_internal_rep( iv_path = iv_path ).
+      ENDIF.
    ELSE.
      lv_internal_target_rep = cv_not_found.
    ENDIF.
  ENDIF.