sdc-build-wp 5.6.9 → 5.6.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/server.js +2 -1
- package/lib/page-script.js +14 -1
- package/package.json +1 -1
package/lib/components/server.js
CHANGED
|
@@ -75,8 +75,9 @@ export default class ServerComponent extends BaseComponent {
|
|
|
75
75
|
rule: {
|
|
76
76
|
match: thisProject.config.browsersync?.location == 'end' ? /<\/body>/ : /<body[^>]*>/,
|
|
77
77
|
fn: function (snippet, match) {
|
|
78
|
+
const exposeProxyScript = `<script>window.localProxyURL = ${JSON.stringify(thisProject.config.browsersync?.localProxyURL || '')};<\/script>`;
|
|
78
79
|
const customScript = `<script async>${thisProject.pageScript}</script>`;
|
|
79
|
-
const allScripts = snippet + customScript;
|
|
80
|
+
const allScripts = snippet + exposeProxyScript + customScript;
|
|
80
81
|
return thisProject.config.browsersync?.location == 'end' ? allScripts + match : match + allScripts;
|
|
81
82
|
}
|
|
82
83
|
}
|
package/lib/page-script.js
CHANGED
|
@@ -13,7 +13,20 @@ function redirectAdminFromPort() {
|
|
|
13
13
|
if (!isAdmin || urlParams.has('keepPort')) {
|
|
14
14
|
return;
|
|
15
15
|
}
|
|
16
|
-
|
|
16
|
+
if (window.localProxyURL && window.localProxyURL !== '') {
|
|
17
|
+
try {
|
|
18
|
+
const proxyUrl = new URL(window.localProxyURL, window.location.origin);
|
|
19
|
+
if (proxyUrl.port) {
|
|
20
|
+
url.port = proxyUrl.port;
|
|
21
|
+
} else {
|
|
22
|
+
url.port = '';
|
|
23
|
+
}
|
|
24
|
+
} catch (e) {
|
|
25
|
+
url.port = '';
|
|
26
|
+
}
|
|
27
|
+
} else {
|
|
28
|
+
url.port = '';
|
|
29
|
+
}
|
|
17
30
|
socket.emit('sdc:redirectAdminFromPort', {
|
|
18
31
|
timestamp: Date.now(),
|
|
19
32
|
port: window.location.port,
|