posit-dev / publisher

MIT License
3 stars 0 forks source link

View Content hits error if user not logged in #1725

Closed sagerb closed 2 months ago

sagerb commented 2 months ago

I published several R projects to my server and saw the same thing. In all cases, if I had a valid login session with the Connect server that I was connecting to, the View Content button worked fine. But if I logged my account out and then tried to visit the server via the same button, I saw this error (not very helpful):

Image

Perhaps this is an error with the version of Connect that I'm running in YETI. It is pretty old, but I don't recall this occurring previously when I had tested this functionality.

sagerb commented 2 months ago

I'm able to reproduce this with my current configuration, as well as resolve it. I think this may warrant some URL normalization code in the backend. My deployment file has these URLs, which have been created from the backend:

bundle_url = 'https://connect.localtest.me/rsc/dev-password//__api__/v1/content/ddf1f075-5449-4a1d-b4f3-fe11779885a6/bundles/2/download'
dashboard_url = 'https://connect.localtest.me/rsc/dev-password//connect/#/apps/ddf1f075-5449-4a1d-b4f3-fe11779885a6'
direct_url = 'https://connect.localtest.me/rsc/dev-password//content/ddf1f075-5449-4a1d-b4f3-fe11779885a6'

Notice the double forward slash after the server URL.

If I am already logged in, these work fine, as is.

However, if I am not logged in, then these URLs hang when I enter them within the Safari (my default browser) address bar.

If I remove the double slash from the URL, then Safari directly is happy.

If I then update the deployment file to not have these double slashes, then my direct navigation from the publisher works as expected.

I believe these probably came in with my credentials...

tdstein commented 2 months ago

This is likely the product of how the URLs are constructed. We can add a type of normalization to the credentials endpoint, but we'll just be playing whack-a-mole. A better solution is to normalize directly before the request is made.

const url = new URL("http://example.com////asdf")
url.protocol + '//' + url.host + url.pathname.replace(/\/+/g, '/') + url.search + url.hash;
http://example.com/adsf