Closed HowardLander closed 5 years ago
That's weird, the nginx / openresty thing should be preventing any CORS issues. I see that it is trying to access http://127.0.0.1
. Which URL are you loading your site on? Is it localhost
? I wonder if we have CORS issues because those are not identical. We might want to switch http://127.0.0.1 to localhost (though this may cause issues on Windows).
@dannyrb knows more about this setup
Hi @swederik
i run dcm4chee-arc on centos with default configuration such as port 8080 and use ohif web viewer on the same system with local_dcm4chee.js config file my proxy setting in package.json file is http://localhost:8080/ but receive this error on browser console
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:8080/dcm4chee-arc/aets/DCM4CHEE/rs/studies?limit=25&offset=0&includefield=00081030%2C00080060&StudyDate=19510129-20190711. (Reason: CORS preflight channel did not succeed).
i try to run ohif with orthanc horos and clearcanvas but every time receive this error on web browser console and i test these browser firefox chrome safari IE and edge i work more than 2 years on ohif but i can't run this pleas help me to run ohif in addition i live in iran and i can't use of docker due to sanctions
@gholamrezaeesaeed That's weird, the proxy should work. Could you check the Create React App docs to ensure it is set up correctly? https://facebook.github.io/create-react-app/docs/proxying-api-requests-in-development
Maybe it shouldn't have a trailing slash?
@swederik thanks for reply i try to solve CORS problem but i need your help
So I may have solved the CORS problem, but something else is popping up. I put this in my config/html/default.js
window.config = {
// default: '/'
routerBasename: '/',
// default: ''
relativeWebWorkerScriptsPath: '',
servers: {
dicomWeb: [
{
name: 'Orthanc',
wadoUriRoot: 'http://localhost/',
qidoRoot: 'http://localhost/',
wadoRoot: 'http://localhost/',
qidoSupportsIncludeField: true,
imageRendering: 'wadors',
thumbnailRendering: 'wadors',
requestOptions: {
requestFromBrowser: true,
},
},
],
},
Then I set up a reverse proxy in nginx to get around the CORS problem
server {
listen 80;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
location /orthanc/ {
proxy_pass http://127.0.0.1:8042;
proxy_set_header HOST $host;
proxy_set_header X-Real-IP $remote_addr;
rewrite /orthanc(.*) $1 break;
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' '*';
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
So I don't get the CORS errors and I do see the Study List window. But I don't get any studies and in the Web console I see this:
Has anyone seen this before? A google search does show this can happen in react.js apps, but I'm don't know how to fix it. Here is the relevant link: https://github.com/facebook/create-react-app/issues/4438 Any ideas?
Thanks Howard
Hmm... Does your local orthanc have a web front-end? Is it possible you're hitting the routes for it, and it's returning HTML with that preview because JS isn't enabled for API calls?
FWIW, our orthanc
nginx
location block looks like this:
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
expires 0;
add_header Cache-Control private;
proxy_pass http://orthanc:8042/;
Notably, we are using all orthanc
plugins (including DICOMWeb), with these settings in our orthanc.json
:
{
...
"AuthenticationEnabled": false,
"DicomWeb": {
"Enable": true,
"Root": "/dicom-web/",
"EnableWado": true,
"WadoRoot": "/wado",
"Host": "127.0.0.1",
"Ssl": false,
"StowMaxInstances": 10,
"StowMaxSize": 10,
"QidoCaseSensitive": false
}
}
Hi Danny
Thanks for the reply and the config info. I'm not sure what you mean by "Does your local orthanc have a web front-end?". We are using orthanc and attempting to access it through the normal API (I think!) but I feel like I am being a bit dense! :) Can you be a little more specific?
Thanks Howard
We don't support the custom Orthanc API, just the DICOMWeb API. Make sure you have the DICOMWeb plugin enabled.
Doesn't this part mean we are using the DICOMWebAPI?
servers: {
dicomWeb: [
{
name: 'Orthanc',
wadoUriRoot: 'https://localhost',
qidoRoot: 'https://localhost',
wadoRoot: 'https://localhost',
qidoSupportsIncludeField: true,
imageRendering: 'wadors',
thumbnailRendering: 'wadors',
requestOptions: {
requestFromBrowser: true,
},
},
],
wadoUriRoot, qidoRoot, and wadoRoot are paths to where some PACS server is serving DICOMWeb endpoints. The default Orthanc API at localhost/ is NOT DICOMWeb, it is their own custom REST API, and pointing OHIF at those endpoints will not work.
Orthanc is typically serving the dicom-web plugin at /dicom-web/, so that's what your wadoUriRoot, qidoRoot, and wadoRoot should be. (in your case localhost/dicom-web since you have a proxy)
Ah, that makes sense. Thanks for the explanation. I'll try this.
Howard
Hmm. Strangely, I am still getting this:
The URL it is trying is:
http://localhost/dicom-web/studies?limit=25&offset=0&includefield=00081030,00080060&StudyDate=19510129-20190711
If it helps any, the response payload is
<!doctype html><html lang="en"><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"/><meta name="theme-color" content="#000000"/><link rel="manifest" href="/manifest.json"/><script type="text/javascript" src="/config/renci.js"></script><title>OHIF Viewer</title><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"/><link href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700|Sanchez&display=swap" rel="stylesheet"/><link href="/static/css/main.b12d4b58.chunk.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>!function(l){function e(e){for(var r,t,n=e[0],o=e[1],u=e[2],f=0,i=[];f<n.length;f++)t=n[f],p[t]&&i.push(p[t][0]),p[t]=0;for(r in o)Object.prototype.hasOwnProperty.call(o,r)&&(l[r]=o[r]);for(s&&s(e);i.length;)i.shift()();return c.push.apply(c,u||[]),a()}function a(){for(var e,r=0;r<c.length;r++){for(var t=c[r],n=!0,o=1;o<t.length;o++){var u=t[o];0!==p[u]&&(n=!1)}n&&(c.splice(r--,1),e=f(f.s=t[0]))}return e}var t={},p={1:0},c=[];function f(e){if(t[e])return t[e].exports;var r=t[e]={i:e,l:!1,exports:{}};return l[e].call(r.exports,r,r.exports,f),r.l=!0,r.exports}f.m=l,f.c=t,f.d=function(e,r,t){f.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},f.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},f.t=function(r,e){if(1&e&&(r=f(r)),8&e)return r;if(4&e&&"object"==typeof r&&r&&r.__esModule)return r;var t=Object.create(null);if(f.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:r}),2&e&&"string"!=typeof r)for(var n in r)f.d(t,n,function(e){return r[e]}.bind(null,n));return t},f.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return f.d(r,"a",r),r},f.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},f.p="/";var r=window.webpackJsonp=window.webpackJsonp||[],n=r.push.bind(r);r.push=e,r=r.slice();for(var o=0;o<r.length;o++)e(r[o]);var s=n;a()}([])</script><script src="/static/js/2.82681181.chunk.js"></script><script src="/static/js/main.b7a7d3c1.chunk.js"></script></body></html>
Does this mean it can't run the script in ortha? Any other ideas of things to try?
Thanks much Howard
The URL you provided wouldn't hit your /orthanc/
location block. There is no /orthanc/
in the URL. That response is the index.html
for your OHIF Viewer client. I believe your wadoUriRoot
needs to be updated so that you'll use the right base-url.
IE. We use an OHIF config file that looks similar to this for dev against a local PACS with a setup similar to yours:
dicomWeb: [
{
name: 'Orthanc',
wadoUriRoot: 'http://127.0.0.1/orthanc/wado',
qidoRoot: 'http://127.0.0.1/orthanc/dicom-web',
wadoRoot: 'http://127.0.0.1/orthanc/dicom-web',
qidoSupportsIncludeField: false,
imageRendering: 'wadors',
thumbnailRendering: 'wadors',
@dannyrb : Did you have to put a line like
"ohif" : [ "OHIFDCM", "localhost", 3000 ]
in the dicom modalities section of your orthanc.json file?
No you don't need to do that because we are communicating over dicomweb, not dimse.
On Fri., Jul. 12, 2019, 4:24 p.m. Howard Lander, notifications@github.com wrote:
@dannyrb https://github.com/dannyrb : Did you have to put a line like
"ohif" : [ "OHIFDCM", "localhost", 3000 ]
in the dicom modalities section of your orthanc.json file?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/OHIF/Viewers/issues/639?email_source=notifications&email_token=AAEUMMLB7HTRKKSIPIOR5ADP7CHZ7A5CNFSM4H7IIMBKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZZ46FQ#issuecomment-510906134, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEUMMK5H5PSZINTT4ZATH3P7CHZ7ANCNFSM4H7IIMBA .
Thanks @swederik The reason I asked is that I am starting to wonder if something is strange about my orthanc setup. I've been trying to access orthanc directly using Firefox and different permutations of what I think should be the correct link, but so far no luck. So for example trying this link:
http://localhost:8042/orthanc/wado/studies
returns a not found. My theory is that if I can get the correct link in the command line, I should be able to configure ohif properly. But the orthanc GUI does work correctly. So this link works:
http://localhost:8042/app/explorer.html#find-studies
in the GUI. so orthanc is not completely busted. Any ideas on what link to try to access the same service that OHIF is trying?
Thanks Howard
Are you able to verify which orthanc extensions/plugins you have added and enabled?
Actually, I'm pretty sure that is the problem. I think the required plugin is missing in orthanc. Will post if that turns out to be the answer.
I've added the plugins in to my build, but what's funny is that the format of the orthanc.json that came along with my ortha build doesn't match either what @dannyrb specified or what the orthanc plugin page for the dicom plugin specifies. So perhaps I am looking at a version mismatch...
Can you update and build the latest version of Orthanc? Or use one of the Osimis-provided builds?
I tend to reference the Orthanc Book
:
Here is the default configuration file:
Orthanc uses the values in that file by default. If you specify a different value, it is used in place of the default. On startup, I think Orthanc scans it's config directory and builds its configuration object from one or more files.
Here is where we overwrite the original configuration file with our own for their docker image:
Thanks everyone for the help. I've made a good amount of progress. I'm running ortha using S6 in a docker and had forgotten to include the name of the ortha config file in the s6 run file! So it was using the default config, which was no fun. Still not quite working, but I can hit the orthanc API in a browser window and see the data I have loaded, so that part seems fine. For example this works fine:
http://localhost:8042/dicom-web/studies
which is real progress. Still getting the COR issue from the viewer without a proxy, so I'm trying to use nginx as a reverse proxy. I think my proxy setup is currently the problem. I'll look carefully at what @dannyrb posted for his above.
Howard
Would this work for you @HowardLander : https://github.com/OHIF/Viewers/issues/663#issuecomment-511347460
Hi @swederik
I tried changing my js file as that comment suggested. No luck. But since I really don't know anything about yarn, I'm wondering about the implications of this comment:
If you use a local copy of Orthanc and you are relying on the proxy part of package.json, you should set the WADO/QIDO roots like this:
My package.json does have a proxy line in it, but I'm not sure if my build is set up to use it. I've got these 2 lines in my build:
yarn install
yarn run build:rencidocker
build:rencidocker in package.json looks like this:
"build:rencidocker": "yarn run preBuild && cross-env REACT_APP_CONFIG=config/renci.js react-scripts --max_old_space_size=4096 build"
Do I have to do something else/different in the build to enable the local proxy (as opposed to trying to configure the nginx reverse proxy)?
Howard
Well, I seem to have it working using nginx to reverse proxy it. That would have been easier if I knew more about what I was doing, and I can't shake the feeling I shouldn't really have to do that. But oh well.
Thanks so much for everyone's help. If anyone is interested, I can post the working config files, but there isn't much interesting, it was just finally getting all of the pieces in place.
Thanks again Howard
Hi all I'm having trouble configuring the newest version of the Viewer to get data from an instance of the OrthaNC server that I have running on the same machine. I'm currently using the config from docker_openresty-orthanc-keycloak.js as start but I am running into
IIIRC, the previous version handled this by using a proxy. How do I configure this version to do so? Or is there some other problem? Any help with this issue would be greatly appreciated.
Howard