Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WS client: Fix connection fails when using dev server #2980

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion bundles/org.openhab.ui/web/src/js/openhab/ws.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ const openWSConnections = []
function newWSConnection (path, messageCallback, readyCallback, errorCallback, heartbeatCallback, heartbeatInterval) {
const encodedToken = btoa(getAccessToken()).replace(/=*$/, '')
// Create a new WebSocket connection
const socket = new WebSocket(path, [`org.openhab.ws.accessToken.base64.${encodedToken}`, 'org.openhab.ws.protocol.default'])
const socket = process?.env?.NODE_ENV === 'development'
? new WebSocket(path + `?access_token=${getAccessToken()}`) // webpack dev server cannot handle our pseudo WS protocols
: new WebSocket(path, [`org.openhab.ws.accessToken.base64.${encodedToken}`, 'org.openhab.ws.protocol.default'])

// Handle WebSocket connection opened
socket.onopen = (event) => {
Expand Down
Loading