Skip to content

Commit

Permalink
fix: make proxy nodejs only (#716)
Browse files Browse the repository at this point in the history
Co-authored-by: Francesco Piccoli <[email protected]>
  • Loading branch information
francescoopiccoli and Francesco Piccoli authored Jan 13, 2025
1 parent b0e6b78 commit 37cf726
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,14 @@ export async function createStreamingClient(
const creds = credentialsProvider.getCredentials('bearer')

let clientOptions
const proxyUrl = process.env.HTTPS_PROXY ?? process.env.https_proxy
const certs = process.env.AWS_CA_BUNDLE ? [readFileSync(process.env.AWS_CA_BUNDLE)] : undefined
// short term solution to fix webworker bundling, broken due to this node.js specific logic in here
const isNodeJS: boolean = typeof process !== 'undefined' && process.release && process.release.name === 'node'
const proxyUrl = isNodeJS ? (process.env.HTTPS_PROXY ?? process.env.https_proxy) : undefined
const certs = isNodeJS
? process.env.AWS_CA_BUNDLE
? [readFileSync(process.env.AWS_CA_BUNDLE)]
: undefined
: undefined

if (proxyUrl) {
const agent = new HttpsProxyAgent({
Expand Down
11 changes: 8 additions & 3 deletions server/aws-lsp-codewhisperer/src/language-server/proxy-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,14 @@ export const QNetTransformServerTokenProxy = QNetTransformServerToken((credentia

export const QChatServerProxy = QChatServer(credentialsProvider => {
let clientOptions: ChatSessionServiceConfig | undefined

const proxyUrl = process.env.HTTPS_PROXY ?? process.env.https_proxy
const certs = process.env.AWS_CA_BUNDLE ? [readFileSync(process.env.AWS_CA_BUNDLE)] : undefined
// short term solution to fix webworker bundling, broken due to this node.js specific logic in here
const isNodeJS: boolean = typeof process !== 'undefined' && process.release && process.release.name === 'node'
const proxyUrl = isNodeJS ? (process.env.HTTPS_PROXY ?? process.env.https_proxy) : undefined
const certs = isNodeJS
? process.env.AWS_CA_BUNDLE
? [readFileSync(process.env.AWS_CA_BUNDLE)]
: undefined
: undefined

if (proxyUrl) {
clientOptions = () => {
Expand Down
10 changes: 8 additions & 2 deletions server/aws-lsp-codewhisperer/src/language-server/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,16 @@ export function getEndPositionForAcceptedSuggestion(content: string, startPositi

export const makeProxyConfig = async (workspace: Workspace) => {
let additionalAwsConfig: ConfigurationOptions = {}
const proxyUrl = process.env.HTTPS_PROXY ?? process.env.https_proxy
// short term solution to fix webworker bundling, broken due to this node.js specific logic in here
const isNodeJS: boolean = typeof process !== 'undefined' && process.release && process.release.name === 'node'
const proxyUrl = isNodeJS ? (process.env.HTTPS_PROXY ?? process.env.https_proxy) : undefined

if (proxyUrl) {
const certs = process.env.AWS_CA_BUNDLE ? [await workspace.fs.readFile(process.env.AWS_CA_BUNDLE)] : undefined
const certs = isNodeJS
? process.env.AWS_CA_BUNDLE
? [await workspace.fs.readFile(process.env.AWS_CA_BUNDLE)]
: undefined
: undefined
const agent = new HttpsProxyAgent({
proxy: proxyUrl,
ca: certs,
Expand Down

0 comments on commit 37cf726

Please sign in to comment.