Skip to content

Dev server doesn't work when used with /etc/hosts mapping #4217

@maxprilutskiy

Description

@maxprilutskiy

Bug report

When I'm using webpack-dev-server in CRA, the WebSocket request URL gets composed incorrectly, if I'm using /etc/hosts to map a domain to localhost for the dev purposes. The code: https://github.com/webpack/webpack-dev-server/blame/master/client-src/utils/createSocketURL.js#L132-:L142

Actual Behavior

Given the app is being accessed via https://app.localhost.dev through reverse proxy pointing to http://127.0.0.1:3000
When I'm starting a CRA app in dev mode
A websocket request is being made to wss://app.localhost.dev:3000/ws

Expected Behavior

Given the app is being accessed via https://app.localhost.dev through reverse proxy pointing to http://127.0.0.1:3000
When I'm starting a CRA app in dev mode
A websocket request is being made to wss://app.localhost.dev/ws

How Do We Reproduce?

app.localhost.dev {
  tls internal
  reverse_proxy 127.0.0.1:3000
}

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