@lwrjs/dev-proxy-server 0.15.0-alpha.2 → 0.15.0-alpha.7
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/build/cjs/index.cjs
CHANGED
|
@@ -25,12 +25,14 @@ var __toModule = (module2) => {
|
|
|
25
25
|
__markAsModule(exports);
|
|
26
26
|
__export(exports, {
|
|
27
27
|
DEFAULT_PROXY_PORT: () => DEFAULT_PROXY_PORT,
|
|
28
|
+
addRemoteProxyMiddleware: () => import_middleware.addRemoteProxyMiddleware,
|
|
28
29
|
createProxyServer: () => createProxyServer,
|
|
29
30
|
findProxyConfiguration: () => findProxyConfiguration
|
|
30
31
|
});
|
|
31
32
|
var import_fs = __toModule(require("fs"));
|
|
32
33
|
var import_path = __toModule(require("path"));
|
|
33
34
|
var import_proxy_server = __toModule(require("./proxy-server.cjs"));
|
|
35
|
+
var import_middleware = __toModule(require("./middleware.cjs"));
|
|
34
36
|
var DEFAULT_PROXY_PORT = 4e3;
|
|
35
37
|
function createProxyServer(config) {
|
|
36
38
|
return new import_proxy_server.LwrProxyServer(config);
|
package/build/cjs/middleware.cjs
CHANGED
|
@@ -55,12 +55,15 @@ function addLocalProxyMiddleware(app, defaultHost) {
|
|
|
55
55
|
}));
|
|
56
56
|
}
|
|
57
57
|
function addRemoteProxyMiddleware(app, proxyConfig) {
|
|
58
|
+
const mobifyRules = process.env.ADD_MOBIFY_PROXY_RULES === "true";
|
|
58
59
|
const {proxyConfigs} = proxyConfig;
|
|
59
60
|
for (const entry of proxyConfigs) {
|
|
60
61
|
const [path, target] = entry;
|
|
61
62
|
const targetHost = target.replace(/^([a-z][a-z0-9+\-.]*):\/\//, "");
|
|
63
|
+
const pathRewrite = mobifyRules && (path.indexOf("/mobify/proxy") === 0 || path.indexOf("/mobify/caching") === 0) ? {[path]: ""} : void 0;
|
|
62
64
|
app.use(path, (0, import_http_proxy_middleware.default)({
|
|
63
65
|
target,
|
|
66
|
+
pathRewrite,
|
|
64
67
|
logLevel: resolveLogLevel(import_diagnostics.logger.getLogLevel()),
|
|
65
68
|
logProvider: () => {
|
|
66
69
|
return import_diagnostics.logger;
|
package/build/es/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import type { LwrProxyServerConfig,
|
|
1
|
+
import type { LwrProxyServerConfig, LwrProxyConfiguration } from './proxy-server.js';
|
|
2
2
|
import { LwrProxyServer } from './proxy-server.js';
|
|
3
3
|
export declare const DEFAULT_PROXY_PORT = 4000;
|
|
4
|
+
export type { LwrProxyConfiguration } from './proxy-server.js';
|
|
5
|
+
export { addRemoteProxyMiddleware } from './middleware.js';
|
|
4
6
|
/**
|
|
5
7
|
* Creates an Development Proxy Server using the provided `LwrProxyServerConfig` configuration.
|
|
6
8
|
* @param config The configuration for the proxy
|
|
@@ -13,7 +15,7 @@ export declare function createProxyServer(config: LwrProxyServerConfig): LwrProx
|
|
|
13
15
|
* - ${rootDir}/config/_proxy
|
|
14
16
|
* @param rootDir The root directory of the project
|
|
15
17
|
* @param buildDir The built distribution directory/
|
|
16
|
-
* @returns The found
|
|
18
|
+
* @returns The found LwrProxyConfiguration object or undefined if no _proxy object could be found.
|
|
17
19
|
*/
|
|
18
|
-
export declare function findProxyConfiguration(rootDir: string, buildDir?: string):
|
|
20
|
+
export declare function findProxyConfiguration(rootDir: string, buildDir?: string): LwrProxyConfiguration | undefined;
|
|
19
21
|
//# sourceMappingURL=index.d.ts.map
|
package/build/es/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import path from 'path';
|
|
|
3
3
|
import { LwrProxyServer } from './proxy-server.js';
|
|
4
4
|
// Default Proxy server port
|
|
5
5
|
export const DEFAULT_PROXY_PORT = 4000;
|
|
6
|
+
export { addRemoteProxyMiddleware } from './middleware.js';
|
|
6
7
|
/**
|
|
7
8
|
* Creates an Development Proxy Server using the provided `LwrProxyServerConfig` configuration.
|
|
8
9
|
* @param config The configuration for the proxy
|
|
@@ -17,7 +18,7 @@ export function createProxyServer(config) {
|
|
|
17
18
|
* - ${rootDir}/config/_proxy
|
|
18
19
|
* @param rootDir The root directory of the project
|
|
19
20
|
* @param buildDir The built distribution directory/
|
|
20
|
-
* @returns The found
|
|
21
|
+
* @returns The found LwrProxyConfiguration object or undefined if no _proxy object could be found.
|
|
21
22
|
*/
|
|
22
23
|
export function findProxyConfiguration(rootDir, buildDir) {
|
|
23
24
|
const PROXY_CONFIG_ROOT = path.join('config', '_proxy');
|
package/build/es/middleware.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Application as ExpressApp } from 'express';
|
|
2
|
-
import type {
|
|
2
|
+
import type { LwrProxyConfiguration } from './proxy-server.js';
|
|
3
3
|
/**
|
|
4
4
|
* The Proxy middleware responsible for proxying all other requests not configured to external systems.
|
|
5
5
|
* @param app
|
|
@@ -11,5 +11,5 @@ export declare function addLocalProxyMiddleware(app: ExpressApp, defaultHost: st
|
|
|
11
11
|
* @param app
|
|
12
12
|
* @param proxyConfig
|
|
13
13
|
*/
|
|
14
|
-
export declare function addRemoteProxyMiddleware(app: ExpressApp, proxyConfig:
|
|
14
|
+
export declare function addRemoteProxyMiddleware(app: ExpressApp, proxyConfig: LwrProxyConfiguration): void;
|
|
15
15
|
//# sourceMappingURL=middleware.d.ts.map
|
package/build/es/middleware.js
CHANGED
|
@@ -41,13 +41,21 @@ export function addLocalProxyMiddleware(app, defaultHost) {
|
|
|
41
41
|
* @param proxyConfig
|
|
42
42
|
*/
|
|
43
43
|
export function addRemoteProxyMiddleware(app, proxyConfig) {
|
|
44
|
+
const mobifyRules = process.env.ADD_MOBIFY_PROXY_RULES === 'true';
|
|
44
45
|
const { proxyConfigs } = proxyConfig;
|
|
45
46
|
for (const entry of proxyConfigs) {
|
|
46
47
|
const [path, target] = entry;
|
|
47
48
|
// remove the scheme from the proxyConfig host.
|
|
48
49
|
const targetHost = target.replace(/^([a-z][a-z0-9+\-.]*):\/\//, '');
|
|
50
|
+
// TODO: Ask Commerce if this rewrite logic can be removed
|
|
51
|
+
// Needed for commerce local-dev when running MRT bundles without a configured Cloudflare CDN
|
|
52
|
+
// Rewrites /mobify/proxy/core and /mobify/caching/core paths (this is what pwa-kit does)
|
|
53
|
+
const pathRewrite = mobifyRules && (path.indexOf('/mobify/proxy') === 0 || path.indexOf('/mobify/caching') === 0)
|
|
54
|
+
? { [path]: '' }
|
|
55
|
+
: undefined;
|
|
49
56
|
app.use(path, proxy({
|
|
50
57
|
target,
|
|
58
|
+
pathRewrite,
|
|
51
59
|
logLevel: resolveLogLevel(logger.getLogLevel()),
|
|
52
60
|
logProvider: () => {
|
|
53
61
|
return logger;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Application as ExpressApp } from 'express';
|
|
2
|
-
export interface
|
|
2
|
+
export interface LwrProxyConfiguration {
|
|
3
3
|
proxyConfigs: ProxyConfigDefinition[];
|
|
4
4
|
}
|
|
5
5
|
type ProxyConfigDefinition = Array<string>;
|
|
6
|
-
export interface LwrProxyServerConfig extends
|
|
6
|
+
export interface LwrProxyServerConfig extends LwrProxyConfiguration {
|
|
7
7
|
port: number;
|
|
8
8
|
defaultHost: string;
|
|
9
9
|
}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.15.0-alpha.
|
|
7
|
+
"version": "0.15.0-alpha.7",
|
|
8
8
|
"homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -33,13 +33,13 @@
|
|
|
33
33
|
"build": "tsc -b"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@lwrjs/diagnostics": "0.15.0-alpha.
|
|
37
|
-
"@lwrjs/shared-utils": "0.15.0-alpha.
|
|
36
|
+
"@lwrjs/diagnostics": "0.15.0-alpha.7",
|
|
37
|
+
"@lwrjs/shared-utils": "0.15.0-alpha.7",
|
|
38
38
|
"express": "^4.19.2",
|
|
39
39
|
"http-proxy-middleware": "0.21.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@lwrjs/types": "0.15.0-alpha.
|
|
42
|
+
"@lwrjs/types": "0.15.0-alpha.7"
|
|
43
43
|
},
|
|
44
44
|
"engines": {
|
|
45
45
|
"node": ">=18.0.0"
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"volta": {
|
|
48
48
|
"extends": "../../../package.json"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "0477351eee6245818acbcd0c0c16baa1fd446321"
|
|
51
51
|
}
|