From 531f14a53bedfac556734055d4d66676e405ccd9 Mon Sep 17 00:00:00 2001 From: dancastillo Date: Sun, 17 Jul 2022 16:14:28 -0500 Subject: [PATCH] docs: updated proxy docs - renamed already used const proxy to proxyServer --- docs/best-practices/proxy.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/docs/best-practices/proxy.md b/docs/best-practices/proxy.md index 256e8f9c147..bf102955cc8 100644 --- a/docs/best-practices/proxy.md +++ b/docs/best-practices/proxy.md @@ -20,10 +20,10 @@ import { createServer } from 'http' import proxy from 'proxy' const server = await buildServer() -const proxy = await buildProxy() +const proxyServer = await buildProxy() const serverUrl = `http://localhost:${server.address().port}` -const proxyUrl = `http://localhost:${proxy.address().port}` +const proxyUrl = `http://localhost:${proxyServer.address().port}` server.on('request', (req, res) => { console.log(req.url) // '/hello?foo=bar' @@ -47,7 +47,7 @@ console.log(response.statusCode) // 200 console.log(JSON.parse(data)) // { hello: 'world' } server.close() -proxy.close() +proxyServer.close() client.close() function buildServer () { @@ -73,12 +73,12 @@ import { createServer } from 'http' import proxy from 'proxy' const server = await buildServer() -const proxy = await buildProxy() +const proxyServer = await buildProxy() const serverUrl = `http://localhost:${server.address().port}` -const proxyUrl = `http://localhost:${proxy.address().port}` +const proxyUrl = `http://localhost:${proxyServer.address().port}` -proxy.authenticate = function (req, fn) { +proxyServer.authenticate = function (req, fn) { fn(null, req.headers['proxy-authorization'] === `Basic ${Buffer.from('user:pass').toString('base64')}`) } @@ -107,7 +107,7 @@ console.log(response.statusCode) // 200 console.log(JSON.parse(data)) // { hello: 'world' } server.close() -proxy.close() +proxyServer.close() client.close() function buildServer () { @@ -124,3 +124,4 @@ function buildProxy () { }) } ``` +