cloudcms-server 0.9.270 → 0.9.271
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/middleware/proxy/proxy.js +5 -9
- package/package.json +2 -2
- package/temp/http-proxy/.auto-changelog +6 -0
- package/temp/http-proxy/.gitattributes +1 -0
- package/temp/http-proxy/CHANGELOG.md +1872 -0
- package/temp/http-proxy/CODE_OF_CONDUCT.md +74 -0
- package/temp/http-proxy/LICENSE +23 -0
- package/temp/http-proxy/README.md +568 -0
- package/temp/http-proxy/codecov.yml +10 -0
- package/temp/http-proxy/index.js +13 -0
- package/temp/http-proxy/lib/http-proxy/common.js +220 -0
- package/temp/http-proxy/lib/http-proxy/index.js +174 -0
- package/temp/http-proxy/lib/http-proxy/passes/web-incoming.js +174 -0
- package/temp/http-proxy/lib/http-proxy/passes/web-outgoing.js +135 -0
- package/temp/http-proxy/lib/http-proxy/passes/ws-incoming.js +141 -0
- package/temp/http-proxy/lib/index.js +13 -0
- package/temp/http-proxy/package.json +41 -0
- package/temp/http-proxy/renovate.json +19 -0
- package/temp/node-http-proxy/.eslintignore +3 -0
- package/temp/node-http-proxy/.eslintrc.js +21 -0
- package/temp/node-http-proxy/.github/workflows/ci.yml +30 -0
- package/temp/node-http-proxy/.prettierrc +7 -0
- package/temp/node-http-proxy/CODE_OF_CONDUCT.md +74 -0
- package/temp/node-http-proxy/LICENSE +23 -0
- package/temp/node-http-proxy/README.md +568 -0
- package/temp/node-http-proxy/codecov.yml +10 -0
- package/temp/node-http-proxy/dist/http-proxy/common.js +220 -0
- package/temp/node-http-proxy/dist/http-proxy/index.js +174 -0
- package/temp/node-http-proxy/dist/http-proxy/passes/web-incoming.js +174 -0
- package/temp/node-http-proxy/dist/http-proxy/passes/web-outgoing.js +135 -0
- package/temp/node-http-proxy/dist/http-proxy/passes/ws-incoming.js +141 -0
- package/temp/node-http-proxy/dist/index.js +13 -0
- package/temp/node-http-proxy/lib/http-proxy/common.js +265 -0
- package/temp/node-http-proxy/lib/http-proxy/index.ts +242 -0
- package/temp/node-http-proxy/lib/http-proxy/passes/web-incoming.js +208 -0
- package/temp/node-http-proxy/lib/http-proxy/passes/web-outgoing.js +163 -0
- package/temp/node-http-proxy/lib/http-proxy/passes/ws-incoming.js +179 -0
- package/temp/node-http-proxy/lib/index.ts +13 -0
- package/temp/node-http-proxy/lib/types.d.ts +277 -0
- package/temp/node-http-proxy/package-lock.json +5028 -0
- package/temp/node-http-proxy/package.json +47 -0
- package/temp/node-http-proxy/tsconfig.build.json +4 -0
- package/temp/node-http-proxy/tsconfig.json +115 -0
- package/temp/node-http-proxy/vitest.config.ts +9 -0
- package/util/proxy-factory.js +39 -128
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "http-proxy",
|
|
3
|
+
"version": "1.18.1",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "https://github.com/http-party/node-http-proxy.git"
|
|
7
|
+
},
|
|
8
|
+
"description": "HTTP proxying for the masses",
|
|
9
|
+
"author": "Charlie Robbins <charlie.robbins@gmail.com>",
|
|
10
|
+
"maintainers": [
|
|
11
|
+
"jcrugzz <jcrugzz@gmail.com>"
|
|
12
|
+
],
|
|
13
|
+
"main": "lib/index.js",
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"eventemitter3": "^4.0.0",
|
|
16
|
+
"follow-redirects": "^1.0.0",
|
|
17
|
+
"requires-port": "^1.0.0"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@types/follow-redirects": "^1.14.1",
|
|
21
|
+
"@types/node": "^18.0.0",
|
|
22
|
+
"@typescript-eslint/eslint-plugin": "^5.31.0",
|
|
23
|
+
"@typescript-eslint/parser": "^5.31.0",
|
|
24
|
+
"async": "^3.0.0",
|
|
25
|
+
"concat-stream": "^2.0.0",
|
|
26
|
+
"eslint": "^8.21.0",
|
|
27
|
+
"eslint-config-prettier": "^8.5.0",
|
|
28
|
+
"prettier": "^2.7.1",
|
|
29
|
+
"semver": "^7.0.0",
|
|
30
|
+
"socket.io": "^4.0.0",
|
|
31
|
+
"socket.io-client": "^4.0.0",
|
|
32
|
+
"sse": "0.0.8",
|
|
33
|
+
"typescript": "^4.8.2",
|
|
34
|
+
"vitest": "^0.20.3",
|
|
35
|
+
"ws": "^8.0.0"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "npx tsc -p ./tsconfig.build.json",
|
|
39
|
+
"format": "prettier --write ./lib",
|
|
40
|
+
"lint": "eslint --fix ./lib",
|
|
41
|
+
"test": "vitest run"
|
|
42
|
+
},
|
|
43
|
+
"engines": {
|
|
44
|
+
"node": ">=14.0.0"
|
|
45
|
+
},
|
|
46
|
+
"license": "MIT"
|
|
47
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
/* Visit https://aka.ms/tsconfig to read more about this file */
|
|
4
|
+
|
|
5
|
+
/* Projects */
|
|
6
|
+
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
|
|
7
|
+
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
|
|
8
|
+
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
|
|
9
|
+
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
|
|
10
|
+
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
|
|
11
|
+
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
|
|
12
|
+
|
|
13
|
+
/* Language and Environment */
|
|
14
|
+
"target": "es2020",
|
|
15
|
+
/* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
|
|
16
|
+
"lib": [
|
|
17
|
+
"es2020"
|
|
18
|
+
],
|
|
19
|
+
/* Specify a set of bundled library declaration files that describe the target runtime environment. */
|
|
20
|
+
// "jsx": "preserve", /* Specify what JSX code is generated. */
|
|
21
|
+
// "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
|
|
22
|
+
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
|
|
23
|
+
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
|
|
24
|
+
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
|
|
25
|
+
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
|
|
26
|
+
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
|
|
27
|
+
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
|
|
28
|
+
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
|
|
29
|
+
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
|
|
30
|
+
|
|
31
|
+
/* Modules */
|
|
32
|
+
"module": "commonjs",
|
|
33
|
+
/* Specify what module code is generated. */
|
|
34
|
+
// "rootDir": "./", /* Specify the root folder within your source files. */
|
|
35
|
+
// "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
|
|
36
|
+
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
|
37
|
+
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
|
38
|
+
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
|
39
|
+
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
|
|
40
|
+
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
|
|
41
|
+
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
|
42
|
+
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
|
|
43
|
+
// "resolveJsonModule": true, /* Enable importing .json files. */
|
|
44
|
+
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
|
|
45
|
+
|
|
46
|
+
/* JavaScript Support */
|
|
47
|
+
"allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
|
|
48
|
+
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
|
|
49
|
+
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
|
|
50
|
+
|
|
51
|
+
/* Emit */
|
|
52
|
+
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
|
|
53
|
+
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
|
|
54
|
+
"emitDeclarationOnly": false, /* Only output d.ts files and not JavaScript files. */
|
|
55
|
+
// "sourceMap": true,
|
|
56
|
+
/* Create source map files for emitted JavaScript files. */
|
|
57
|
+
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
|
|
58
|
+
"outDir": "./dist", /* Specify an output folder for all emitted files. */
|
|
59
|
+
// "removeComments": true, /* Disable emitting comments. */
|
|
60
|
+
"noEmit": false, /* Disable emitting files from a compilation. */
|
|
61
|
+
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
|
|
62
|
+
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
|
|
63
|
+
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
|
|
64
|
+
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
|
|
65
|
+
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
|
66
|
+
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
|
|
67
|
+
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
|
|
68
|
+
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
|
|
69
|
+
// "newLine": "crlf", /* Set the newline character for emitting files. */
|
|
70
|
+
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
|
|
71
|
+
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
|
|
72
|
+
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
|
|
73
|
+
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
|
|
74
|
+
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
|
|
75
|
+
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
|
|
76
|
+
|
|
77
|
+
/* Interop Constraints */
|
|
78
|
+
"isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
|
|
79
|
+
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
|
|
80
|
+
"esModuleInterop": true,
|
|
81
|
+
/* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
|
|
82
|
+
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
|
|
83
|
+
"forceConsistentCasingInFileNames": true,
|
|
84
|
+
/* Ensure that casing is correct in imports. */
|
|
85
|
+
|
|
86
|
+
/* Type Checking */
|
|
87
|
+
"strict": true,
|
|
88
|
+
/* Enable all strict type-checking options. */
|
|
89
|
+
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
|
|
90
|
+
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
|
|
91
|
+
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
|
|
92
|
+
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
|
|
93
|
+
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
|
|
94
|
+
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
|
|
95
|
+
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
|
|
96
|
+
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
|
|
97
|
+
// "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
|
|
98
|
+
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
|
|
99
|
+
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
|
|
100
|
+
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
|
|
101
|
+
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
|
|
102
|
+
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
|
|
103
|
+
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
|
|
104
|
+
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
|
|
105
|
+
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
|
|
106
|
+
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
|
|
107
|
+
|
|
108
|
+
/* Completeness */
|
|
109
|
+
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
|
110
|
+
"skipLibCheck": true
|
|
111
|
+
/* Skip type checking all .d.ts files. */
|
|
112
|
+
},
|
|
113
|
+
"exclude": ["node_modules", "benchmark", "dist"],
|
|
114
|
+
"include": ["examples", "lib", "test"]
|
|
115
|
+
}
|
package/util/proxy-factory.js
CHANGED
|
@@ -73,7 +73,10 @@ var createProxyHandler = function(proxyTarget, pathPrefix)
|
|
|
73
73
|
// This must appear at the top of the app.js file (ahead of config) for things to work
|
|
74
74
|
//
|
|
75
75
|
////////////////////////////////////////////////////////////////////////////
|
|
76
|
-
|
|
76
|
+
|
|
77
|
+
// parse the target to get host
|
|
78
|
+
var proxyHost = urlTool.parse(proxyTarget).host;
|
|
79
|
+
|
|
77
80
|
// NOTE: changeOrigin must be true because of the way that we set host to host:port
|
|
78
81
|
// in http-proxy's common.js line 102, the host is only properly set up if changeOrigin is set to true
|
|
79
82
|
// this sets the "host" header and it has to match what is set at the network/transport level in a way
|
|
@@ -84,21 +87,25 @@ var createProxyHandler = function(proxyTarget, pathPrefix)
|
|
|
84
87
|
"agent": http.globalAgent,
|
|
85
88
|
"xfwd": false,
|
|
86
89
|
"proxyTimeout": process.defaultHttpTimeoutMs,
|
|
87
|
-
"changeOrigin": true
|
|
90
|
+
//"changeOrigin": true
|
|
91
|
+
"headers": {
|
|
92
|
+
"host": proxyHost
|
|
93
|
+
},
|
|
94
|
+
"cookieDomainRewrite": true
|
|
88
95
|
};
|
|
89
96
|
|
|
90
97
|
// use https?
|
|
91
98
|
if (util.isHttps(proxyTarget))
|
|
92
99
|
{
|
|
93
|
-
// parse the target to get host
|
|
94
|
-
var proxyHost = urlTool.parse(proxyTarget).host;
|
|
95
|
-
|
|
96
100
|
proxyConfig = {
|
|
97
101
|
"target": proxyTarget,
|
|
98
102
|
"agent": https.globalAgent,
|
|
103
|
+
"xfwd": false,
|
|
104
|
+
"proxyTimeout": process.defaultHttpTimeoutMs,
|
|
99
105
|
"headers": {
|
|
100
106
|
"host": proxyHost
|
|
101
|
-
}
|
|
107
|
+
},
|
|
108
|
+
"cookieDomainRewrite": true
|
|
102
109
|
};
|
|
103
110
|
}
|
|
104
111
|
|
|
@@ -129,7 +136,9 @@ var createProxyHandler = function(proxyTarget, pathPrefix)
|
|
|
129
136
|
// and if we hear it, we automatically invalidate the SSO chain so that the next request
|
|
130
137
|
// will continue to work
|
|
131
138
|
proxyServer.on("proxyRes", function (proxyRes, req, res) {
|
|
132
|
-
|
|
139
|
+
|
|
140
|
+
console.log("proxyRes.1");
|
|
141
|
+
|
|
133
142
|
if (req.gitana_user)
|
|
134
143
|
{
|
|
135
144
|
var chunks = [];
|
|
@@ -140,6 +149,8 @@ var createProxyHandler = function(proxyTarget, pathPrefix)
|
|
|
140
149
|
});
|
|
141
150
|
|
|
142
151
|
proxyRes.on("end", function () {
|
|
152
|
+
|
|
153
|
+
console.log("proxyRes.end, code: " + proxyRes.statusCode);
|
|
143
154
|
|
|
144
155
|
if (proxyRes.statusCode === 401)
|
|
145
156
|
{
|
|
@@ -195,6 +206,15 @@ var createProxyHandler = function(proxyTarget, pathPrefix)
|
|
|
195
206
|
|
|
196
207
|
var proxyHandlerServer = http.createServer(function(req, res) {
|
|
197
208
|
|
|
209
|
+
console.log("proxy.1: " + req.url);
|
|
210
|
+
if (req.headers)
|
|
211
|
+
{
|
|
212
|
+
for (var k in req.headers)
|
|
213
|
+
{
|
|
214
|
+
console.log("proxy.2 header " + k + " = " + req.headers[k]);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
198
218
|
// used to auto-assign the client header for /oauth/token requests
|
|
199
219
|
oauth2.autoProxy(req);
|
|
200
220
|
|
|
@@ -253,130 +273,10 @@ var createProxyHandler = function(proxyTarget, pathPrefix)
|
|
|
253
273
|
|
|
254
274
|
// set x-cloudcms-server-version header
|
|
255
275
|
req.headers["x-cloudcms-server-version"] = process.env.CLOUDCMS_APPSERVER_PACKAGE_VERSION;
|
|
256
|
-
|
|
257
|
-
// determine the domain to set the "host" header on the proxied call
|
|
258
|
-
// this is what we pass to the API server
|
|
259
|
-
var cookieDomain = req.domainHost;
|
|
260
|
-
|
|
261
|
-
// if the incoming request is coming off of a CNAME entry that is maintained elsewhere (and they're just
|
|
262
|
-
// forwarding the CNAME request to our machine), then we try to detect this...
|
|
263
|
-
//
|
|
264
|
-
// our algorithm here is pretty weak but suffices for the moment.
|
|
265
|
-
// if the req.headers["x-forwarded-host"] first entry is in the req.headers["referer"] then we consider
|
|
266
|
-
// things to have been CNAME forwarded
|
|
267
|
-
// and so we write cookies back to the req.headers["x-forwarded-host"] first entry domain
|
|
268
|
-
/*
|
|
269
|
-
var xForwardedHost = req.headers["x-forwarded-host"];
|
|
270
|
-
if (xForwardedHost)
|
|
271
|
-
{
|
|
272
|
-
xForwardedHost = xForwardedHost.split(",");
|
|
273
|
-
if (xForwardedHost.length > 0)
|
|
274
|
-
{
|
|
275
|
-
var cnameCandidate = xForwardedHost[0];
|
|
276
|
-
|
|
277
|
-
var referer = req.headers["referer"];
|
|
278
|
-
if (referer && referer.indexOf("://" + cnameCandidate) > -1)
|
|
279
|
-
{
|
|
280
|
-
req.log("Detected CNAME: " + cnameCandidate);
|
|
281
|
-
|
|
282
|
-
proxyHostHeader = cnameCandidate;
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
*/
|
|
287
|
-
|
|
288
|
-
// we fall back to using http-node-proxy's xfwd support
|
|
289
|
-
// thus, spoof header here on request so that "x-forwarded-host" is set properly
|
|
290
|
-
//req.headers["host"] = proxyHostHeader;
|
|
291
|
-
|
|
276
|
+
|
|
292
277
|
// keep alive
|
|
293
278
|
req.headers["connection"] = "keep-alive";
|
|
294
279
|
|
|
295
|
-
// allow forced cookie domains
|
|
296
|
-
var forcedCookieDomain = req.headers["cloudcmscookiedomain"];
|
|
297
|
-
if (!forcedCookieDomain)
|
|
298
|
-
{
|
|
299
|
-
if (process.env.CLOUDCMS_FORCE_COOKIE_DOMAIN)
|
|
300
|
-
{
|
|
301
|
-
forcedCookieDomain = process.env.CLOUDCMS_FORCE_COOKIE_DOMAIN;
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
if (forcedCookieDomain)
|
|
305
|
-
{
|
|
306
|
-
cookieDomain = forcedCookieDomain;
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
var updateSetCookieValue = function(value)
|
|
310
|
-
{
|
|
311
|
-
// replace the domain with the host
|
|
312
|
-
var i = value.toLowerCase().indexOf("domain=");
|
|
313
|
-
if (i > -1)
|
|
314
|
-
{
|
|
315
|
-
var j = value.indexOf(";", i);
|
|
316
|
-
if (j === -1)
|
|
317
|
-
{
|
|
318
|
-
value = value.substring(0, i);
|
|
319
|
-
}
|
|
320
|
-
else
|
|
321
|
-
{
|
|
322
|
-
value = value.substring(0, i) + value.substring(j);
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
// if the originating request isn't secure, strip out "secure" from cookie
|
|
327
|
-
if (!util.isSecure(req))
|
|
328
|
-
{
|
|
329
|
-
var i = value.toLowerCase().indexOf("; secure");
|
|
330
|
-
if (i > -1)
|
|
331
|
-
{
|
|
332
|
-
value = value.substring(0, i);
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
// if the original request is secure, ensure cookies have "secure" set
|
|
337
|
-
if (util.isSecure(req))
|
|
338
|
-
{
|
|
339
|
-
var i = value.toLowerCase().indexOf("; secure");
|
|
340
|
-
var j = value.toLowerCase().indexOf(";secure");
|
|
341
|
-
if (i === -1 && j === -1)
|
|
342
|
-
{
|
|
343
|
-
value += ";secure";
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
return value;
|
|
348
|
-
};
|
|
349
|
-
|
|
350
|
-
// handles the setting of response headers
|
|
351
|
-
// we filter off stuff we do not care about
|
|
352
|
-
// we ensure proper domain on set-cookie (TODO: is this needed anymore?)
|
|
353
|
-
var _setHeader = res.setHeader;
|
|
354
|
-
res.setHeader = function(key, value)
|
|
355
|
-
{
|
|
356
|
-
var _key = key.toLowerCase();
|
|
357
|
-
|
|
358
|
-
if (_key.indexOf("access-control-") === 0)
|
|
359
|
-
{
|
|
360
|
-
// skip any access control headers
|
|
361
|
-
}
|
|
362
|
-
else
|
|
363
|
-
{
|
|
364
|
-
if (_key === "set-cookie")
|
|
365
|
-
{
|
|
366
|
-
for (var x in value)
|
|
367
|
-
{
|
|
368
|
-
value[x] = updateSetCookieValue(value[x]);
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
var existing = this.getHeader(key);
|
|
373
|
-
if (!existing)
|
|
374
|
-
{
|
|
375
|
-
_setHeader.call(this, key, value);
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
};
|
|
379
|
-
|
|
380
280
|
// if the incoming request didn't have an "Authorization" header
|
|
381
281
|
// and we have a logged in Gitana User via Auth, then set authorization header to Bearer Access Token
|
|
382
282
|
if (!req.headers["authorization"])
|
|
@@ -394,8 +294,19 @@ var createProxyHandler = function(proxyTarget, pathPrefix)
|
|
|
394
294
|
if (pathPrefix) {
|
|
395
295
|
req.url = path.join(pathPrefix, req.url);
|
|
396
296
|
}
|
|
297
|
+
|
|
298
|
+
console.log("proxy.4: " + req.url);
|
|
299
|
+
if (req.headers)
|
|
300
|
+
{
|
|
301
|
+
for (var k in req.headers)
|
|
302
|
+
{
|
|
303
|
+
console.log("proxy.4 header " + k + " = " + req.headers[k]);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
397
306
|
|
|
398
307
|
proxyServer.web(req, res);
|
|
308
|
+
|
|
309
|
+
console.log("proxy.5");
|
|
399
310
|
});
|
|
400
311
|
|
|
401
312
|
return proxyHandlerServer.listeners('request')[0];
|