cancel
Showing results for 
Search instead for 
Did you mean: 

adf-viewer causes 401 after deploy

d_moeyersons
Star Contributor
Star Contributor

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:

GET https://o-alfresco.vmm.be/alfresco/api/-default-/public/alfresco/versions/1/nodes/5c62ee00-6a32-4406... 401 (Unauthorized)

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?

17 REPLIES 17

dvuika
Star Collaborator
Star Collaborator

Can you please provide any extra details, i.e. what are the browser error details in the Network tab. The stack traces if there's a JS error during that call, etc.

d_moeyersons
Star Contributor
Star Contributor

Details

Network tab capture

Request URL: https://o-alfresco.vmm.be/alfresco/api/-default-/public/alfresco/versions/1/nodes/1370f78d-0eb0-4ddf...
Request Method: GET
Status Code: 401 Unauthorized
Remote Address: 192.168.130.117:443
Referrer Policy: no-referrer-when-downgrade
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: https://o-dms.vmm.be
Content-Length: 360
Content-Type: text/html;charset=UTF-8
Date: Mon, 17 Sep 2018 13:24:27 GMT
Server: webserver
Set-Cookie: JSESSIONID=B35178E11C94A8CE9C8E75181863F001; Path=/alfresco/; HttpOnly
Vary: Origin
WWW-Authenticate: Negotiate
Accept: */*
Accept-Encoding: gzip, deflate, br
Accept-Language: nl-NL,nl;q=0.9,en-US;q=0.8,en;q=0.7
Connection: keep-alive
Host: o-alfresco.vmm.be
Origin: https://o-dms.vmm.be
Referer: https://o-dms.vmm.be/dms/vergadersite/vgd-test-vergadersite/vergadering/be6c3e3d-58d1-4629-b838-6601...
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36
attachment: false
alf_ticket: TICKET_994a22cb59b72a8a5849bb88b051256b12d21643

There are no js errors.

Have you tried same request with Postman? to check if your Tomcat is correctly configured and URL indeed works?

Hi Denys,

I tried it now. The request works fine with Postman. I get a pdf with the content of the document.

it looks like your configuration issue in tomcat could you maybe try to follow this guide :

Enabling CORS in Apache 

Hi Eugenio,

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.

David.

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?

David.

eugenio_romano
Elite Collaborator
Elite Collaborator

Sorry but I am not able to replicate this problem it could be maybe simple if you provide something to try

Hi Eugenio,

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.

Thanks!

David.