Skip to content

Codespace Websocket Support #797

@cpietsch

Description

@cpietsch

It would be great to have vite running in a github codespace container.
Right now it works, but without Websockets because of the port forwarding.

Codespace will forward eg. port 3000 to an xxxx.apps.codespaces.githubusercontent.com (port 80).
Vite tries to connect to the port which is a global constant and is different then the proxied port.

console.log('[vite] connecting...');
const socketProtocol = location.protocol === 'https:' ? 'wss' : 'ws';
const socketUrl = `${socketProtocol}://${location.hostname}:${3000}`;
const socket = new WebSocket(socketUrl, 'vite-hmr');

When serverd via the codespace server proxy, port 80 is mapped to 3000 internally. So we would need to adjust the port accordingly when using codespace.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions