Skip to content
GitLab
    • Explore Projects Groups Snippets
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C create-react-app
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,547
    • Issues 1,547
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 417
    • Merge requests 417
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Meta
  • create-react-app
  • Merge requests
  • !12861
An error occurred while fetching the assigned milestone of the selected merge_request.

improve websocketurl flexibility

  • Review changes

  • Download
  • Email patches
  • Plain diff
Open Administrator requested to merge github/fork/ruckc/websocketurl into main 2 years ago
  • Overview 1
  • Commits 1
  • Pipelines 0
  • Changes 5

Created by: ruckc

referencing #12860 - improve flexibility of the webSocketURL property from webpack-dev-server.

Compare
  • version 1
    87a49bc6
    2 years ago

  • main (HEAD)

and
  • latest version
    87a49bc6
    1 commit, 2 years ago

  • version 1
    87a49bc6
    1 commit, 2 years ago

5 files
+ 59
- 40

    Preferences

    File browser
    Compare changes

Some changes are not shown

For a faster browsing experience, some files are collapsed by default.

docusau‎rus/docs‎
advanced-con‎figuration.md‎ +26 -23
pack‎ages‎
react-d‎ev-utils‎
WebpackDevSe‎rverUtils.js‎ +3 -1
webpackHotD‎evClient.js‎ +11 -8
react-scri‎pts/config‎
env‎.js‎ +2 -0
webpackDevSer‎ver.config.js‎ +17 -8
docusaurus/docs/advanced-configuration.md
+ 26
- 23
  • View file @ dc498c5a

  • Edit in single-file editor

  • Open in Web IDE

Files with large changes are collapsed by default.

packages/react-dev-utils/WebpackDevServerUtils.js
+ 3
- 1
  • View file @ dc498c5a

  • Edit in single-file editor

  • Open in Web IDE


@@ -320,7 +320,9 @@ function prepareProxy(proxy, appPublicFolder, servedPathname) {
@@ -320,7 +320,9 @@ function prepareProxy(proxy, appPublicFolder, servedPathname) {
// If proxy is specified, let it handle any request except for
// If proxy is specified, let it handle any request except for
// files in the public folder and requests to the WebpackDevServer socket endpoint.
// files in the public folder and requests to the WebpackDevServer socket endpoint.
// https://github.com/facebook/create-react-app/issues/6720
// https://github.com/facebook/create-react-app/issues/6720
const sockPath = process.env.WDS_SOCKET_PATH || '/ws';
const sockUrl =
 
process.env.WDS_SOCKET_URL && url.parse(process.env.WDS_SOCKET_URL);
 
const sockPath = process.env.WDS_SOCKET_PATH || sockUrl.path || '/ws';
const isDefaultSockHost = !process.env.WDS_SOCKET_HOST;
const isDefaultSockHost = !process.env.WDS_SOCKET_HOST;
function mayProxy(pathname) {
function mayProxy(pathname) {
const maybePublicPath = path.resolve(
const maybePublicPath = path.resolve(
packages/react-dev-utils/webpackHotDevClient.js
+ 11
- 8
  • View file @ dc498c5a

  • Edit in single-file editor

  • Open in Web IDE


@@ -58,14 +58,17 @@ if (module.hot && typeof module.hot.dispose === 'function') {
@@ -58,14 +58,17 @@ if (module.hot && typeof module.hot.dispose === 'function') {
// Connect to WebpackDevServer via a socket.
// Connect to WebpackDevServer via a socket.
var connection = new WebSocket(
var connection = new WebSocket(
url.format({
process.env.WDS_SOCKET_URL ||
protocol: window.location.protocol === 'https:' ? 'wss' : 'ws',
url.format({
hostname: process.env.WDS_SOCKET_HOST || window.location.hostname,
protocol:
port: process.env.WDS_SOCKET_PORT || window.location.port,
process.env.WDS_SOCKET_PROTOCOL || window.location.protocol === 'https:'
// Hardcoded in WebpackDevServer
? 'wss'
pathname: process.env.WDS_SOCKET_PATH || '/ws',
: 'ws',
slashes: true,
hostname: process.env.WDS_SOCKET_HOST || window.location.hostname,
})
port: process.env.WDS_SOCKET_PORT || window.location.port,
 
pathname: process.env.WDS_SOCKET_PATH || '/ws',
 
slashes: true,
 
})
);
);
// Unlike WebpackDevServer client, we won't try to reconnect
// Unlike WebpackDevServer client, we won't try to reconnect
packages/react-scripts/config/env.js
+ 2
- 0
  • View file @ dc498c5a

  • Edit in single-file editor

  • Open in Web IDE


@@ -93,6 +93,8 @@ function getClientEnvironment(publicUrl) {
@@ -93,6 +93,8 @@ function getClientEnvironment(publicUrl) {
WDS_SOCKET_HOST: process.env.WDS_SOCKET_HOST,
WDS_SOCKET_HOST: process.env.WDS_SOCKET_HOST,
WDS_SOCKET_PATH: process.env.WDS_SOCKET_PATH,
WDS_SOCKET_PATH: process.env.WDS_SOCKET_PATH,
WDS_SOCKET_PORT: process.env.WDS_SOCKET_PORT,
WDS_SOCKET_PORT: process.env.WDS_SOCKET_PORT,
 
WDS_SOCKET_PROTOCOL: process.env.WDS_SOCKET_PROTOCOL,
 
WDS_SOCKET_URL: process.env.WDS_SOCKET_URL,
// Whether or not react-refresh is enabled.
// Whether or not react-refresh is enabled.
// It is defined here so it is available in the webpackHotDevClient.
// It is defined here so it is available in the webpackHotDevClient.
FAST_REFRESH: process.env.FAST_REFRESH !== 'false',
FAST_REFRESH: process.env.FAST_REFRESH !== 'false',
packages/react-scripts/config/webpackDevServer.config.js
+ 17
- 8
  • View file @ dc498c5a

  • Edit in single-file editor

  • Open in Web IDE


@@ -17,9 +17,25 @@ const paths = require('./paths');
@@ -17,9 +17,25 @@ const paths = require('./paths');
const getHttpsConfig = require('./getHttpsConfig');
const getHttpsConfig = require('./getHttpsConfig');
const host = process.env.HOST || '0.0.0.0';
const host = process.env.HOST || '0.0.0.0';
 
const sockUrl = process.env.WDS_SOCKET_URL;
const sockHost = process.env.WDS_SOCKET_HOST;
const sockHost = process.env.WDS_SOCKET_HOST;
const sockPath = process.env.WDS_SOCKET_PATH; // default: '/ws'
const sockPath = process.env.WDS_SOCKET_PATH; // default: '/ws'
const sockPort = process.env.WDS_SOCKET_PORT;
const sockPort = process.env.WDS_SOCKET_PORT;
 
const sockProtocol = process.env.WDS_SOCKET_PROTOCOL;
 
 
// 1st priority is WDS_SOCKET_URL (if exists)
 
// 2nd priority is the object from the parameters
 
const sockObject = sockUrl
 
? sockUrl
 
: {
 
// Enable custom sockjs pathname for websocket connection to hot reloading server.
 
// Enable custom sockjs hostname, pathname and port for websocket connection
 
// to hot reloading server.
 
hostname: sockHost,
 
pathname: sockPath,
 
port: sockPort,
 
protocol: sockProtocol,
 
};
module.exports = function (proxy, allowedHost) {
module.exports = function (proxy, allowedHost) {
const disableFirewall =
const disableFirewall =
@@ -78,14 +94,7 @@ module.exports = function (proxy, allowedHost) {
@@ -78,14 +94,7 @@ module.exports = function (proxy, allowedHost) {
},
},
},
},
client: {
client: {
webSocketURL: {
webSocketURL: sockObject,
// Enable custom sockjs pathname for websocket connection to hot reloading server.
// Enable custom sockjs hostname, pathname and port for websocket connection
// to hot reloading server.
hostname: sockHost,
pathname: sockPath,
port: sockPort,
},
overlay: {
overlay: {
errors: true,
errors: true,
warnings: false,
warnings: false,
0 Assignees
None
Assign to
0 Reviewers
None
Request review from
Labels
0
None
0
None
    Assign labels
  • Manage project labels

Milestone
No milestone
None
None
Time tracking
No estimate or time spent
Lock merge request
Unlocked
0
0 participants
Reference:
Source branch: github/fork/ruckc/websocketurl

Menu

Explore Projects Groups Snippets