diff options
Diffstat (limited to 'app/server/proxy.js')
| -rw-r--r-- | app/server/proxy.js | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/app/server/proxy.js b/app/server/proxy.js index b6ca14c..2dcc1d7 100644 --- a/app/server/proxy.js +++ b/app/server/proxy.js @@ -33,11 +33,11 @@ function serve(req, res) { console.log(req.method, req.url) - // if (USE_CACHE && req.method == 'GET' && req.url in cache) { - // res.writeHeader(200, { 'Content-type': 'application/json' }) - // res.end(cache[req.url]) - // return - // } + if (process.env.PROXY_CACHE && req.method == 'GET' && req.url in cache) { + res.writeHeader(200, { 'Content-type': 'application/json' }) + res.end(cache[req.url]) + return + } // console.log(req.headers) @@ -61,12 +61,12 @@ function serve(req, res) { res.writeHeader(server_res.statusCode, server_res.headers) server_res.pipe(res) - // if (! options.headers['x-yoox-cart-token']) { - // cache[req.url] = '' - // server_res.on('data', function(s){ - // cache[req.url] += s.toString() - // }) - // } + if (process.env.PROXY_CACHE) { + cache[req.url] = '' + server_res.on('data', function(s){ + cache[req.url] += s.toString() + }) + } if (DEBUG) { server_res.on('data', s => console.log(s.toString())) |
