This repository has been archived by the owner on Mar 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: change secure cookie to unsecure (#1138)
PR Close #1135
- Loading branch information
1 parent
77f3735
commit 721b6cd
Showing
4 changed files
with
77 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
const CLOUDSTACK_ENDPOINT = 'https://example.com/'; | ||
/* | ||
* Plugins endpoint | ||
* https://github.com/bwsw/cloudstack-ui#plugins-supported | ||
* */ | ||
const PULSE_PLUGIN_ENDPOINT = 'http://example.com:8081'; | ||
const WEBSHELL_PLUGIN_ENDPOINT = 'http://example.com:8082'; | ||
|
||
function onProxyRes(proxyRes, req, res) { | ||
var cookies = proxyRes.headers[ 'set-cookie' ]; | ||
var cookieRegex = /Secure/i; | ||
console.log(cookies); | ||
|
||
if (cookies) { | ||
var newCookie = cookies.map(function (cookie) { | ||
if (cookieRegex.test(cookie)) { | ||
return cookie.replace(cookieRegex, ''); | ||
} | ||
return cookie; | ||
}); | ||
delete proxyRes.headers[ 'set-cookie' ]; | ||
proxyRes.headers[ 'set-cookie' ] = newCookie; | ||
} | ||
} | ||
|
||
const apiProxyConfig = { | ||
context: [ | ||
'/client/api', | ||
'/client/console' | ||
], | ||
target: CLOUDSTACK_ENDPOINT, | ||
secure: false | ||
}; | ||
|
||
// If server works over https need to change Secure Cookie | ||
if (CLOUDSTACK_ENDPOINT.indexOf('https') === 0) { | ||
apiProxyConfig.onProxyRes = onProxyRes; | ||
} | ||
|
||
const pulseProxyConfig = { | ||
context: [ '/cs-extensions/pulse/**' ], | ||
target: PULSE_PLUGIN_ENDPOINT, | ||
secure: false, | ||
pathRewrite: { '^/cs-extensions/pulse': '' } | ||
}; | ||
|
||
const webShellProxyConfig = { | ||
context: [ '/cs-extensions/webshell/**' ], | ||
target: WEBSHELL_PLUGIN_ENDPOINT, | ||
secure: false, | ||
pathRewrite: { '^/cs-extensions/webshell': '' } | ||
} | ||
|
||
const PROXY_CONFIG = [ | ||
apiProxyConfig, | ||
// pulseProxyConfig, | ||
// webShellProxyConfig | ||
]; | ||
|
||
module.exports = PROXY_CONFIG; |