Skip to content

Support secure websocket connections#1537

Merged
ovidiuch merged 3 commits intoreact-cosmos:mainfrom
kmjennison:kevin/wss-support
Jul 21, 2023
Merged

Support secure websocket connections#1537
ovidiuch merged 3 commits intoreact-cosmos:mainfrom
kmjennison:kevin/wss-support

Conversation

@kmjennison
Copy link
Contributor

Closes #1525.

@ovidiuch ovidiuch merged commit 3824c75 into react-cosmos:main Jul 21, 2023
@ovidiuch
Copy link
Member

@kmjennison Great contribution, thanks 🙌

Pushed the changes under 6.0.0-beta.6.

Just an FYI, I made a subsequent PR (#1539) to clean up some stuff:

  • Applied Prettier and removed ESLint supressions, otherwise left source code the same.
  • Refactored the tests to be more in line with existing tests and practices. I can offer more details if you want.

Really appreciate taking the time to make the changes and test everything!

@kmjennison
Copy link
Contributor Author

Wonderful, thanks for the follow-up! Glad I could help.

@kmjennison
Copy link
Contributor Author

@skidding Are you sure this made it into the latest release? I installed v6.0.0-beta.6 and still see the insecure websocket. In addition, cat node_modules/react-cosmos-dom/dist/domRendererConnect.js shows:

import { createPostMessageConnect, createWebSocketsConnect, } from 'react-cosmos-core';
import { isInsideCosmosPreviewIframe } from './utils/isInsideCosmosPreviewIframe.js';
export function createDomRendererConnect(playgroundUrl) {
    return isInsideCosmosPreviewIframe()
        ? createPostMessageConnect()
        : createWebSocketsConnect(getWebSocketsUrl(playgroundUrl));
}
function getWebSocketsUrl(playgroundUrl) {
    return playgroundUrl.replace(/^https?:/, 'ws:');
}

@ovidiuch
Copy link
Member

ovidiuch commented Jul 21, 2023

@kmjennison I think so. Make sure to install all Cosmos packages you use with @next . For example: react-cosmos@next react-cosmos-plugin-vite@next etc.

Also, you can browse the published code here: https://www.npmjs.com/package/react-cosmos-dom/v/6.0.0-beta.6?activeTab=code – the file you mentioned doesn't exist in this version.

@ovidiuch
Copy link
Member

@kmjennison Let me know if upgrading all packages worked, otherwise I'd like to help find the issue.

@kmjennison
Copy link
Contributor Author

@skidding This is working and all good! My yarn.lock was resolving to an older canary release. Thanks!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Respect SSL option when connecting to websocket

2 participants