Skip to Content
0
Feb 22, 2019 at 11:42 PM

SAP Hana XSA Deployment and Routing Clarifications (CORS, mtaext)

456 Views Last edit May 21, 2020 at 03:20 PM 2 rev

Hi,

I have a developed an MTA project in WebIDE consisting of db, js, and web (html5/nodejs) modules. I have few questions:

1. Our system was already installed using Port Based Routing. So, every application/module gets deployed with its own port number. However, these port numbers are dynamic. However, we need to know the port numbers ahead of time as we need the exact URLs of some of these apps. One way we figured so far to pre-set the port number is to use an .mtaext file. This works. However, what is the best practice to create a well-known route in the port based routing?

2. I am following "SAP Hana Developer Guide for SAP Hana XS Advanced Model" version 1.1.

https://help.sap.com/doc/6165d52d8f534ea1a9c5aff17a672f64/2.0.03/en-US/SAP_HANA_Developer_Guide_for_SAP_HANA_XS_Advanced_Model_en.pdf

On page 849, it talks about CORS environment variable. On page 851, there is an example of a sample manifest.yml file. However, it seems to me that manifest.yml file does not work with mtar files. We are supposed to use ".mtaext" files to extend the mtar files. I tried creating a mtaext file and appplying that to the app during deployment with a command as below:

>> XS <mtar file> -e <mtaext file>

My mtaext file looks something like below:

----Begin of mtaext-----

_schema-version: "3.1"

ID: MyApp.config1

extends: MyApp

modules:

- name: web

parameters:

memory: 2048M

port: 51101

env:

CORS: >

[

{

"allowedMethods": ["GET","OPTIONS","POST","PUT"],

"allowedOrigin":[{

"host":".*",

"protocol":"https"}],

"uriPattern":".*"

}

]

---End of mtaext ----

I noticed that the memory and port are being accepted. But any environment variable set using the 'env' parameter is ignored. I can see the environment variables using the command line:

>> XS env MyApp.web

So, one other option I could think of was to set environment manually using the command line option such as

>> XS set-env MyApp.web CORS --from-file <file that contains value of the CORS enviroment>

That sets the environment.

So, my question are: Does CORS environment variable work for NodeJS applications. If they do, what is the correct way to set them.

Even after setting the CORS environment manually (using XS set-env), any pre flight calls by Chrome fails stating the method "OPTIONS" is unimplemented.

I tried the default URL under postman with GET as the method, and got the correct result. But when I tried the same URL using OPTIONS as the method, I get error 405 (method not allowed). How can I make sure any OPTIONS request gets valid response?

Thank you.