Skip to content

Files

Latest commit

86785ea · Oct 2, 2024

History

History
357 lines (249 loc) · 6.77 KB
·

routing-configuration-file-c103fb4.md

File metadata and controls

357 lines (249 loc) · 6.77 KB
·

Routing Configuration File

The routing configuration defined in the xs-app.json file contains the properties used by the application router.

The following example of an xs-app.json application descriptor shows the JSON-compliant syntax required and the properties that either must be set or can be specified as an additional option.

Code Syntax:

{
  "welcomeFile": "index.html",
  "authenticationMethod": "route",
  "sessionTimeout": 10,
  "pluginMetadataEndpoint": "/metadata",
  "routes": [				
    {
      "source": "^/sap/ui5/1(.*)$",
      "target": "$1",
      "destination": "ui5",
      "csrfProtection": false
    },
    {
      "source": "/employeeData/(.*)",
	  "target": "/services/employeeService/$1",
	  "destination": "employeeServices",
	  "authenticationType": "xsuaa",
	  "scope": ["$XSAPPNAME.viewer", "$XSAPPNAME.writer"],
	  "csrfProtection": true
    },
    {
      "source": "^/(.*)$",
      "target": "/web/$1",
      "localDir": "static-content",
	  "replace": {
        "pathSuffixes": ["/abc/index.html"],
        "vars": ["NAME"]
     }, 
     {
        "source": "^/user-api(.*)",
        "target": "$1",
        "service": "sap-approuter-userapi"
      }       
    }
  ],
  "login": {
     "callbackEndpoint": "/custom/login/callback"
  },
  "logout": {
     "logoutEndpoint": "/my/logout",
     "logoutPage": "/logout-page.html"
  },
  "destinations": {
     "employeeServices": {
       "logoutPath": "/services/employeeService/logout",
       "logoutMethod": "GET"
     }
  }, 
  "responseHeaders" : [
    {"name": "Content-Security-Policy", "value": "default-src 'self'"}
  ],
  "compression": { 
     "minSize": 2048
  },
  "whitelistService": {
     "endpoint": "/whitelist/service"
  },
  "websockets": {
    "enabled": true
  },
  "errorPage": [
    {"status": [400,401,402], "file": "/custom-err-4xx.html"},
    {"status": 501, "file": "/custom-err-501.html"}
  ] 
}

The following table lists the properties that either must be set or can be specified as an additional option. Click on the links for information for each property:

Property

Type

Description

welcomeFile

String

The Web page served by default if the HTTP request does not include a specific path, for example, index.html.

authenticationMethod

String

The method used to authenticate user requests, for example: “route” or “none” (no authentication).

sessionTimeout

Number

Define the amount of time (in minutes) for which a session can remain inactive before it closes automatically (times out); the default time out is 15 minutes.

Note:

We recommend using the environment variable SESSION_TIMEOUT to configure the session timeout.

If the environment variable SESSION_TIMEOUT is set this property will be overwritten.

Note:

You can configure sessionTimeout only in the central routing configuration file (xs-app.json) that belongs to the application router, not in an xs-app.json file that is part of an HTML5 application.

routes

Array

Defines all route objects, for example: source, target, and, destination.

login

Object

A redirect to the application router at a specific endpoint takes place during OAuth2 authentication with the User Account and Authentication service (UAA).

logout

Object

You can define any options that apply if you want your application to have central log out end point.

destinations

Object

Specify any additional options for your destinations.

services

Object

Specify options for a service in your application.

responseHeaders

Array

Add custom response headers to your application.

compression

Object

The compression keyword enables you to define if the application router compresses text resources before sending them.

pluginMetadataEndpoint

String

Adds an endpoint that serves a JSON string representing all configured plugins.

whitelistService

Object

Enable the allowlist service to help preventing click-jacking attacks.

websockets

Object

The application router can forward web-socket communication. Web-socket communication must be enabled in the application router configuration.

errorPage

Array

Errors originating in the application router show the HTTP status code of the error. It is possible to display a custom error page using the errorPage property.

Related Information

Application Router

Application Router Configuration