Skip to content

websocket URL ending with a "/" won't work #1041

@vgu-natbraille

Description

@vgu-natbraille

Description

A nginx rule out of my reach redirects public facing somehost.name/ws/ to the hocuspocus server on port 1234 of the vps.

But it is not possible to set wss://somehost.name/ws/ (or https://somehost.name/ws/ for what it's worth) in my web client HocuspocusProvider because :

@hocuspocus/provider/src/HocuspocusProviderWebsocket.ts

// Ensure that the URL never ends with /
	get serverUrl() {
		while (this.configuration.url[this.configuration.url.length - 1] === "/") {
			return this.configuration.url.slice(0, this.configuration.url.length - 1);
		}

		return this.configuration.url;
	}

Am I missing something ? Is there a rationale for that ?

Steps to reproduce the bug
Steps to reproduce the behavior:

  1. Have a websocket URL ending with a "/"
  2. Try to set this URL in Provider
  3. Cannot connect (in my case 301)

Expected behavior
I can connect to a URL ending with a "/"

Screenshot, video, or GIF
N/A

Environment?

  • operating system:all
  • browser:all
  • mobile/desktop:all
  • Hocuspocus version: "@hocuspocus/provider": "^3.4.0", and above

Additional context
N/A

Anyway, thanks for this great software !

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions