PP 9.2 REST based WebSerice and CORS (cross-orgin resource sharing)

Hello All,

 

 

  I created a protocol in pp9.2 and am trying to access via launhJob….

When I access it via typing the URL on the browser, everything works fine… but when I do via javascript using XMLHTTPRequest from my localhost I get then

XMLHttpRequest cannot load http://pipelinepilot:9944/auth/anon/launchjob?_protocol={4F18019B-CCC6-4A53-9B44-407A5A178134. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access.

In PP how do I enable CORS..?

Thanks,

Ravi

Answers 6
LM
LM 2014-08-25

Hello,

It does not appear that CORS is currently supported for this specific case.  I will enter an enhancement request on your behalf as I do not see that this has been previously requested by other customers.

For today you might consider using the JavaScript Client SDK to create the protocol request rather than calling launchjob.

Best wishes,

Lynn Miller

BIOVIA Support

HP
HP 2014-08-26

Hi All,

Modification of the Apache config is the correct solution for adding CORS headers. See here:

http://enable-cors.org/server_apache.html.

However, I recommend adding this configuration in a different place.

1. Templates

The main httpd.conf file is over-written many times by a process called replace tokens (DBUtil.exe -t). This process uses templates from the $sciroot/install/templates folder. It would be better to pick the appropriate tempalte from there and modify it, then run $sciroot/bin/DBUtil.exe -t and restart Apache. This will prevent you from losing your changes when other configuration edits are made through the admin portal.

2. HTTP Conf Fragments

You can also add configuration file fragments to $sciroot/web/conf. There are many examples there and adding configuration extensions for packages by copying files to this directory is an idomatic way to customize the Apache configuration.

3. htaccess files

Finally, you can add CORS headers on per-job basis by writing a .htaccess file to the root job directory. We use this methodology for setting headers on result file downloads. In this case, you would setup a writing component to add the .htaccess file from your protocol.

Jason

BIOVIA Foundation and Pipeline Pilot R&D

MP
MP 2014-08-26

Hi,

I've the same problem and i have solved it using this workaround:

open:

     "C:\Program Files\Accelrys\AEP\apps\scitegic\core\packages_win64\apache\httpd-2.2.22\conf\httpd.conf"

add the following lines:

    

Header add Access-Control-Allow-Origin "http://$hostname:$port"

Header add Access-Control-Allow-Headers "origin, x-requested-with, content-type, X-Pilot-Session"

Header add Access-Control-Allow-Methods "PUT, GET, POST, DELETE, OPTIONS"

Header add Access-Control-Allow-Credentials "true"

Best wishes,

Mattia


ravindra.mamidipaka ha scritto:

Hello All,

  I created a protocol in pp9.2 and am trying to access via launhJob….

When I access it via typing the URL on the browser, everything works fine… but when I do via javascript using XMLHTTPRequest from my localhost I get then

XMLHttpRequest cannot load http://pipelinepilot:9944/auth/anon/launchjob?_protocol={4F18019B-CCC6-4A53-9B44-407A5A178134. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access.

In PP how do I enable CORS..?

Thanks,

Ravi

RM
RM 2014-08-26

Hello Mattia,

  Thank you very much ... I think this should fix it..

Thanks again,

Ravi

LM
LM 2014-09-09

Hello,

There is no general mechanism for modifying the Apache configuration file from within the admin portal.

The easiest mechanism to use and support is to add additional required lines into a file with a .conf file extension in the web/conf folder as described by Jason above.

Best wishes,

Lynn Miller

BIOVIA support

CB
CB 2014-09-09

Is it possible to simply set parameters in Admin page/Setup/Global Properties  ?

Ch