Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Meta
create-react-app
Merge requests
!596
Proxy: add websocket support
Code
Review changes
Check out branch
Download
Email patches
Plain diff
Closed
Administrator
requested to merge
github/fork/gutenye/websocket
into
master
8 years ago
Overview
7
Commits
1
Pipelines
0
Changes
1
Created by: gutenye
0
0
Compare
master
master (base)
and
latest version
latest version
87118037
1 commit,
2 years ago
1 file
+
12
-
11
Expand all files
Preferences
Preferences
File browser
List view
Tree view
Compare changes
Inline
Side-by-side
Show whitespace changes
Show one file at a time
scripts/start.js
+
12
-
11
Options
View file @ 87118037
Show full file
@@ -229,17 +229,18 @@ function addMiddleware(devServer) {
// - /sockjs-node/* (WebpackDevServer uses this for hot reloading)
// Tip: use https://www.debuggex.com/ to visualize the regex
var
mayProxy
=
/^
(?!\/(
index
\.
html$|.*
\.
hot-update
\.
json$|sockjs-node
\/))
.*$/
;
devServer
.
use
(
mayProxy
,
// Pass the scope regex both to Express and to the middleware for proxying
// of both HTTP and WebSockets to work without false positives.
httpProxyMiddleware
(
pathname
=>
mayProxy
.
test
(
pathname
),
{
target
:
proxy
,
logLevel
:
'
silent
'
,
onError
:
onProxyError
(
proxy
),
secure
:
false
,
changeOrigin
:
true
})
);
// Pass the scope regex both to Express and to the middleware for proxying
// of both HTTP and WebSockets to work without false positives.
var
proxyMiddleware
=
httpProxyMiddleware
(
pathname
=>
mayProxy
.
test
(
pathname
),
{
target
:
proxy
,
logLevel
:
'
silent
'
,
onError
:
onProxyError
(
proxy
),
secure
:
false
,
changeOrigin
:
true
,
ws
:
true
,
});
devServer
.
use
(
mayProxy
,
proxyMiddleware
);
devServer
.
listeningApp
.
on
(
'
upgrade
'
,
proxyMiddlware
.
upgrade
);
}
// Finally, by now we have certainly resolved the URL.
// It may be /index.html, so let the dev server try serving it again.
Menu
Explore
Projects
Groups
Snippets