# Orthanc + OHIF Viewer V3 + Nginx ?

**URL:** https://discourse.orthanc-server.org/t/orthanc-ohif-viewer-v3-nginx/3296
**Category:** Google Groups archive
**Created:** [March 8, 2023, 12:16pm UTC](https://discourse.orthanc-server.org/t/orthanc-ohif-viewer-v3-nginx/3296 "2023-03-08T12:16:04Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![ranasrule](https://discourse.orthanc-server.org/letter_avatar_proxy/v4/letter/r/3e96dc/32.png) [@ranasrule](https://discourse.orthanc-server.org/u/ranasrule)
#### Post date: [March 8, 2023, 12:16pm UTC](https://discourse.orthanc-server.org/t/orthanc-ohif-viewer-v3-nginx/3296/1 "2023-03-08T12:16:04Z")

</div>

I have been pulling my hair out over the last three days trying to figure this out without any luck…

I have no idea if this is the right place but since I know a lot of Orthanc users use OHIF viewer with Orthanc it seems logical to ask here…

OHIF V3 with Orthanc MPR functionality works fine on localhost but **Error: Uncaught (in promise) Error: SharedArrayBuffer is NOT supported in your browser see [https://developer.chrome.com/blog/enabling-shared-array-buffer/](https://developer.chrome.com/blog/enabling-shared-array-buffer/)** error occurs when accessing over that internet

Steps to Reproduce:

1. open any study on localhost and switch to MPR view. It will work find
2. open any study over the internet and switch to MPR view. It will generate **Error: Uncaught (in promise) Error: SharedArrayBuffer is NOT supported in your browser see [https://developer.chrome.com/blog/enabling-shared-array-buffer/](https://developer.chrome.com/blog/enabling-shared-array-buffer/)** error in browser console and MPR will not generate.  
my nginx config file is below:

**worker\_processes 1;**

**events { worker\_connections 1024; }**

**http {**

**upstream orthanc-server {**  
**server 127.0.0.1:8099;**  
**}**

**server {**  
**listen [::]:8099 default\_server;**  
**listen 8099;**

**# CORS Magic**  
**add\_header ‘Access-Control-Allow-Origin’ ‘\*’;**  
**add\_header ‘Access-Control-Allow\_Credentials’ ‘true’;**  
**add\_header ‘Access-Control-Allow-Headers’ ‘Authorization,Accept,Origin,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range’;**  
**add\_header ‘Access-Control-Allow-Methods’ ‘GET,POST,OPTIONS,PUT,DELETE,PATCH’;**

**location / {**

**if ($request\_method = ‘OPTIONS’) {**  
**add\_header ‘Access-Control-Allow-Origin’ ‘_';_**  
 _ **add\_header ‘Access-Control-Allow\_Credentials’ ‘true’;**  
 **add\_header ‘Access-Control-Allow-Headers’ ‘Authorization,Accept,Origin,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range’;**  
 **add\_header ‘Access-Control-Allow-Methods’ ‘GET,POST,OPTIONS,PUT,DELETE,PATCH’;**  
 **add\_header ‘Access-Control-Max-Age’ 1728000;**  
 **add\_header ‘Content-Type’ ‘text/plain charset=UTF-8’;**  
 **add\_header ‘Content-Length’ 0;**  
 **return 204;**  
 **}**  
 **try\_files $uri $uri/ /index.html;**  
 **add\_header ‘Access-Control-Allow-Credentials’ ‘true’;**  
 **add\_header ‘Access-Control-Allow-Headers’ ‘DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type’;**  
 **add\_header ‘Access-Control-Allow-Methods’ ‘GET, POST, OPTIONS’;**  
 **add\_header ‘Access-Control-Allow-Origin’ '** _ **’;**  
**add\_header Cross-Origin-Opener-Policy same-origin;**  
**add\_header Cross-Origin-Embedder-Policy require-corp;**  
**add\_header Cross-Origin-Resource-Policy same-origin;**  
**}**

**location /orthanc/{**

**proxy\_pass [http://localhost:8042](http://localhost:8042);**  
**proxy\_set\_header Authorization “Basic YWxuYXNhcnBhY3MbyybyybNhcnBhY3M1Nzc=”;**  
**proxy\_set\_header Host $Host:8099/orthanc/;**  
**proxy\_set\_header X-Real-IP $remote\_addr;**  
**proxy\_set\_header X-Forwarded-For $proxy\_add\_x\_forwarded\_for;**  
**proxy\_set\_header X-Forwarded-Host $server\_name;**

**# CORS Magic**  
**add\_header ‘Access-Control-Allow-Origin’ '_';_**  
 _ **add\_header ‘Access-Control-Allow\_Credentials’ ‘true’;**  
 **add\_header ‘Access-Control-Allow-Headers’ ‘Authorization,Accept,Origin,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range’;**  
 **add\_header ‘Access-Control-Allow-Methods’ ‘GET,POST,OPTIONS,PUT,DELETE,PATCH’;**  
\_\_rewrite /orthanc(._) $1 break;\_\_  
**}**  
**}**

**}**

My OHIF app-config.js is below

**window.config = {**  
**routerBasename: “/”,**  
**extensions: [],**  
**modes: [],**  
**customizationService: {},**  
**showStudyList: !0,**  
**maxNumberOfWebWorkers: 3,**  
**omitQuotationForMultipartRequest: !0,**  
**showWarningMessageForCrossOrigin: !0,**  
**showCPUFallbackMessage: !0,**  
**showLoadingIndicator: !0,**  
**maxNumRequests: {**  
**interaction: 100,**  
**thumbnail: 75,**  
**prefetch: 10**  
**},**  
**dataSources: [{**  
**friendlyName: “dcmjs DICOMWeb Server”,**  
**namespace: “@ohif/extension-default.dataSourcesModule.dicomweb”,**  
**sourceName: “dicomweb”,**  
**configuration: {**  
**name: “aws”,**  
**wadoUriRoot: ‘/orthanc/wado’,**  
**qidoRoot: ‘/orthanc/dicom-web’,**  
**wadoRoot: ‘/orthanc/dicom-web’,**  
**qidoSupportsIncludeField: !1,**  
**supportsReject: !1,**  
**imageRendering: “wadors”,**  
**thumbnailRendering: “wadors”,**  
**enableStudyLazyLoad: !1,**  
**supportsFuzzyMatching: !1,**  
**supportsWildcard: !0,**  
**staticWado: !0,**  
**singlepart: “bulkdata,video,pdf”**  
**}**  
**}, {**  
**friendlyName: “dicom json”,**  
**namespace: “@ohif/extension-default.dataSourcesModule.dicomjson”,**  
**sourceName: “dicomjson”,**  
**configuration: {**  
**name: “json”**  
**}**  
**}, {**  
**friendlyName: “dicom local”,**  
**namespace: “@ohif/extension-default.dataSourcesModule.dicomlocal”,**  
**sourceName: “dicomlocal”,**  
**configuration: {}**  
**}],**  
**httpErrorHandler: e =\> {**  
**console.warn(e.status), console.warn(“test, navigate to [https://ohif.org/](https://ohif.org/)”)**  
**},**  
**defaultDataSourceName: “dicomweb”,**

**};**

The current behavior:  
OHIF V3 with Orthanc MPR functionality works fine on localhost but Error: Uncaught (in promise) Error: SharedArrayBuffer is NOT supported in your browser see [https://developer.chrome.com/blog/enabling-shared-array-buffer/](https://developer.chrome.com/blog/enabling-shared-array-buffer/) error occurs when accessing over that internet

The expected behavior:  
It should work over the internet as well as localhost

I tried using the example nginx config file here as a guide \>\>\> [https://github.com/OHIF/Viewers/blob/master/.docker/Nginx-Orthanc/config/nginx.conf](https://github.com/OHIF/Viewers/blob/master/.docker/Nginx-Orthanc/config/nginx.conf) but no luck.

---

<div class="post-metadata">

### Author: ![James\_Manners](https://discourse.orthanc-server.org/letter_avatar_proxy/v4/letter/j/a9adbd/32.png) [@James\_Manners](https://discourse.orthanc-server.org/u/James_Manners)
#### Post date: [March 8, 2023, 7:15pm UTC](https://discourse.orthanc-server.org/t/orthanc-ohif-viewer-v3-nginx/3296/2 "2023-03-08T19:15:40Z")

</div>

SharedArrayBuffer is only available if you are accessing a secure (https) site. Are you using https to serve the site?

James

---

<div class="post-metadata">

### Author: ![cali](https://discourse.orthanc-server.org/user_avatar/discourse.orthanc-server.org/cali/32/1796_2.png) [@cali](https://discourse.orthanc-server.org/u/cali)
#### Post date: [March 9, 2023, 5:28pm UTC](https://discourse.orthanc-server.org/t/orthanc-ohif-viewer-v3-nginx/3296/3 "2023-03-09T17:28:56Z")

</div>

Hello Rana,

Your Orthanc and NGINX configurations are correct. You need to add the cross-origin headers to the server running OHIF Viewer itself for the MPR functionality to work. Add the following headers to server you’re hosting OHIF Viewer on:

Cross-Origin-Embedder-Policy: require-corp  
Cross-Origin-Opener-Policy: same-origin

I use S3 and CloudFront as my solution for hosting OHIF Viewer. If you’ve got a similar environment then I can help you to get them added there.
