allow for proxy for getting product data

This commit is contained in:
Wingysam 2018-11-21 14:12:59 -05:00
parent 7d9fdc0b13
commit 634d4cfabb
2 changed files with 3 additions and 1 deletions

View file

@ -3,6 +3,7 @@ module.exports = {
dbUrl: process.env.DB_URL || 'db', dbUrl: process.env.DB_URL || 'db',
defaultFailureRedirect: process.env.DEFAULT_FAILURE_REDIRECT || '/login', defaultFailureRedirect: process.env.DEFAULT_FAILURE_REDIRECT || '/login',
port: process.env.PORT || 3000, port: process.env.PORT || 3000,
proxyServer: process.env.PROXY_SERVER || undefined,
secret: process.env.SECRET || require('uuid/v4')(), secret: process.env.SECRET || require('uuid/v4')(),
siteTitle: process.env.SITE_TITLE || 'Christmas Community' siteTitle: process.env.SITE_TITLE || 'Christmas Community'
}; };

View file

@ -2,6 +2,7 @@ const verifyAuth = require('../../middlewares/verifyAuth');
const getProductName = require('get-product-name'); const getProductName = require('get-product-name');
const bcrypt = require('bcrypt-nodejs'); const bcrypt = require('bcrypt-nodejs');
const express = require('express'); const express = require('express');
const config = require('../../config');
const uuid = require('uuid/v4'); const uuid = require('uuid/v4');
const totals = wishlist => { const totals = wishlist => {
@ -45,7 +46,7 @@ module.exports = (db) => {
const item = {}; const item = {};
let productData; let productData;
try { try {
if (isUrl) productData = await getProductName(req.body.itemUrlOrName); if (isUrl) productData = await getProductName(req.body.itemUrlOrName, config.proxyServer);
} catch (err) {} } catch (err) {}
item.name = (productData ? productData.name : req.body.itemUrlOrName); item.name = (productData ? productData.name : req.body.itemUrlOrName);
item.addedBy = req.user._id; item.addedBy = req.user._id;