When I deploy my app to my webserver (Tomcat v7.0.59) when I try to preview any document (with adf-viewer), the document viewer doesn't show it and the console log shows a 401 error like this:
The link works if i copy it and open it in a new browser window. In development mode (npm run start) all the previews work fine. I only get a 401 on previews. CORS is configured and working fine, I get no CORS errors either.
The problem started after i updated my app from ADF v2.4.0 to v2.5.0
If i make a new ADF 2.5.0 app, and deploy it without code changes, i get the same problem.
Does anyone else have this experience or have an idea what could cause this?
Network tab capture
Request URL: https://o-alfresco.vmm.be/alfresco/api/-default-/public/alfresco/versions/1/nodes/1370f78d-0eb0-4ddf...
There are no js errors.
I have tried this implementation that you mention before, both globally as wel as in the webapp, I have never gotten it working with Alfresco.
I currently use the CORS implementation that is commented out in the alfresco.war\WEB-INF\web.xml . It works fine. And there is no reason that it shouldn't work with the document viewer.
Also if there are CORS error: the console messages should mention it, it doesn't. And CORS is disabled in my Internet Explorer and MS Edge, and it also fails there, this is no CORS problem.
I also tried it in Apache HTTP server, I got exactly the same error.
There is a difference between the call that causes 401 and the other calls.
CORS is active, the headers are returned (as you can see in the logs), so that is not the problem & CORS doesn't trigger 401.
But there is no Authorization header, instead a alf_ticket is added. Why is that?
I did some more tests today, I only get the error because my Alfresco server and ADF app are on different servers.
(ADF runs on the same server as the share environment - We have one server for the database Postgres, one server for the Alfresco platform environment, one server for the Share and ADF environment)
When I upload the ADF app to the Alfresco platform (back-end) server, I get no errors.
I also checked the Alfresco logs for csrf errors when the 401 error shows up, i get no such errors.
Have you tried both the Alfresco platform server and the ADF client on one server, or have you tried it on different servers?
My current ADF app is created for a customized Alfresco server, it has several Java extensions especially made for our organisation, it won't work well on a standard Alfresco setup. But I get the same errors with the ADF demo application: alfresco-ng2-components/demo-shell at master · Alfresco/alfresco-ng2-components · GitHub
Let me know if that is enough or you need more information.