Skip to content

fix: 3.0 Client cannot connect to server on subdirectory - #1776

Merged
tassoevan merged 2 commits into
RocketChat:masterfrom
ura14h:fix-subdir-url
Oct 3, 2020
Merged

fix: 3.0 Client cannot connect to server on subdirectory#1776
tassoevan merged 2 commits into
RocketChat:masterfrom
ura14h:fix-subdir-url

Conversation

@ura14h

@ura14h ura14h commented Oct 3, 2020

Copy link
Copy Markdown
Contributor

Closes #1775

@tassoevan tassoevan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, we need to get that resolved URL for instances reached by a URL that replies a HTTP 3xx response. I guess it should be fix at the fetchServerInformation() function itself.

@ura14h

ura14h commented Oct 3, 2020

Copy link
Copy Markdown
Contributor Author

Thank you for pointing out. I have confirmed that the additional commit by tassoevan works on my server.

@tassoevan tassoevan modified the milestones: 3.0.2, 3.0.3 Oct 3, 2020
@tassoevan
tassoevan merged commit 50c8585 into RocketChat:master Oct 3, 2020
Comment thread src/servers/main.ts
return [new URL('/', convertToURL(response.url)), responseBody.version];
const finalEndpoint = convertToURL(response.url);

return [new URL('../..', finalEndpoint), responseBody.version];

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tassoevan
Excuse me for pointing out late, maybe there are too many .. ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, the URL for reference is <server-root>/api/info.

@ura14h ura14h Oct 14, 2020

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested another server url such https://foo.bar/apps/chat/, then the result is https://foo.bar/apps which losts /chat.

So, I tried a one liner test:

console.log((new URL('../..', 'https://foo.bar/apps/chat' + '/api/info')).href); // -> 'https://foo.bar/apps/'
console.log((new URL('..', 'https://foo.bar/apps/chat' + '/api/info')).href); // -> 'https://foo.bar/apps/chat/'

Thanks.

@huhmare huhmare Oct 14, 2020

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can confirm:

Windows Rocket.Chat.Electron 3.0.3, rocketchat URL: http://foo.bar/rocketchat. Does not work. DevTool shows that it makes successfull query to http://foo.bar/rocketchat/api/info (HTTP 200, {version: "3.1.1", success: true}).

console.log((new URL('../..', 'http://foo.bar/rocketchat/api/info')).href); // -> 'https://foo.bar/'

new URL semantic is relative to the last full url path segment (last separator "/"). As example:
console.log((new URL('../..', 'http://foo.bar/rocketchat/api/info/')).href); // -> http://foo.bar/rocketchat/

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh man, you guys are right. I forgot that previously I was traversing a URL with the trailing slash. Please wait, I'll try to add some tests to assert this kind of stuff.

@julijane

Copy link
Copy Markdown

@tassoevan I'm confused here. Is this supposed to be fixed in 3.0.3? Because we have the issue with 3.0.3 still.

@ura14h

ura14h commented Oct 15, 2020

Copy link
Copy Markdown
Contributor Author

The same issue is still open. #1796

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3.0 Client cannot connect to server on subdirectory

4 participants