REST API Cross Side Scripting

457 views
Skip to first unread message

tobi...@gmail.com

unread,
Apr 25, 2014, 4:35:44 AM4/25/14
to orthan...@googlegroups.com
Hey,

I'm trying to implement a customized Website to upload/list/preview Data from Orthanc. The REST API ist very nice as long as the Orthanc Server is the same as the webserver where the website is hosted.

Is there any possibility to query data via REST API without to violate the Same-Origin-Policy? I tried to use JSONP with AJAX but Orthanc didn't seem to support callback functions.

Is there any other solution for this problem or am I completely off the track?

Best
Tobi

Sébastien Jodogne

unread,
Apr 25, 2014, 4:40:12 AM4/25/14
to orthan...@googlegroups.com, tobi...@gmail.com
Hello,

The most direct way to avoid the Same-Origin-Policy restrictions would be to "mount" the REST API of Orthanc in some path of your Web server. This is called reverse proxying. Instructions for Apache are given in our FAQ:

HTH,
Sébastien-

tobi...@gmail.com

unread,
Apr 25, 2014, 7:47:13 AM4/25/14
to orthan...@googlegroups.com, tobi...@gmail.com
Hey Sébastien,

funny, I came across this solution almost at the same moment you posted this answer.
Thank you - this solved my problem!

Best, Tobi

祁晓浪

unread,
Jul 21, 2014, 11:54:55 PM7/21/14
to orthan...@googlegroups.com, tobi...@gmail.com
For anyone uses nginx for webserver, modify these lines in your nginx config file:
server{
       listen  80  default_server;
       ...
       location  /orthanc/  {
                proxy_pass http://localhost:8042;
proxy_set_header HOST $host;
                proxy_set_header X-Real-IP $remote_addr;
                rewrite /orthanc(.*) $1 break;
        }
        ...
}



在 2014年4月25日星期五UTC+8下午4时35分44秒,tobi...@gmail.com写道:

Sébastien Jodogne

unread,
Jul 22, 2014, 2:29:06 AM7/22/14
to orthan...@googlegroups.com, tobi...@gmail.com
Dear Qaler,

Thanks for this information! I have just included it in the FAQ:

Cheers,
Sébastien-
Reply all
Reply to author
Forward
0 new messages