We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6e0d846 commit 0266bbbCopy full SHA for 0266bbb
packages/@vue/cli/lib/ui.js
@@ -5,10 +5,14 @@ const shortid = require('shortid')
5
function simpleCorsValidation (allowedHost) {
6
return function (req, socket) {
7
const { host, origin } = req.headers
8
- // maybe we should just use strict string equal?
9
- const hostRegExp = new RegExp(`^https?://(${host}|${allowedHost}|localhost)(:\\d+)?$`)
10
11
- if (!origin || !hostRegExp.test(origin)) {
+ const safeOrigins = [
+ host,
+ allowedHost,
12
+ 'localhost'
13
+ ]
14
+
15
+ if (!origin || !safeOrigins.includes(new URL(origin).hostname)) {
16
socket.destroy()
17
}
18
0 commit comments