From 634d4cfabbdc8346fc4437aa5cb6f4ff0a954349 Mon Sep 17 00:00:00 2001 From: Wingysam Date: Wed, 21 Nov 2018 14:12:59 -0500 Subject: [PATCH] allow for proxy for getting product data --- config/index.js | 1 + routes/wishlist/index.js | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/config/index.js b/config/index.js index afb8523..b559670 100644 --- a/config/index.js +++ b/config/index.js @@ -3,6 +3,7 @@ module.exports = { dbUrl: process.env.DB_URL || 'db', defaultFailureRedirect: process.env.DEFAULT_FAILURE_REDIRECT || '/login', port: process.env.PORT || 3000, + proxyServer: process.env.PROXY_SERVER || undefined, secret: process.env.SECRET || require('uuid/v4')(), siteTitle: process.env.SITE_TITLE || 'Christmas Community' }; diff --git a/routes/wishlist/index.js b/routes/wishlist/index.js index 1e53c07..c5b7491 100644 --- a/routes/wishlist/index.js +++ b/routes/wishlist/index.js @@ -2,6 +2,7 @@ const verifyAuth = require('../../middlewares/verifyAuth'); const getProductName = require('get-product-name'); const bcrypt = require('bcrypt-nodejs'); const express = require('express'); +const config = require('../../config'); const uuid = require('uuid/v4'); const totals = wishlist => { @@ -45,7 +46,7 @@ module.exports = (db) => { const item = {}; let productData; try { - if (isUrl) productData = await getProductName(req.body.itemUrlOrName); + if (isUrl) productData = await getProductName(req.body.itemUrlOrName, config.proxyServer); } catch (err) {} item.name = (productData ? productData.name : req.body.itemUrlOrName); item.addedBy = req.user._id;