12 Commits 1eb1ef3e2d ... 295e85dac4

Author SHA1 Message Date
  wanyongkang 295e85dac4 salary修复 6 years ago
  wayne b4540a2a41 修复bug 6 years ago
  wayne f5c06058da 修复bug 6 years ago
  wayne d4e6fa48f7 修复bug 6 years ago
  wayne 9fb30d94b0 修复bug 6 years ago
  lushuncheng 51ce6f236c revert https 6 years ago
  lushuncheng debff1cd44 demo ssr 6 years ago
  lushuncheng 788b378b03 Merge branch 'master' into dev 6 years ago
  wayne bce45c86a4 修复bug 6 years ago
  xiaozhen 09722ef4b7 Merge branch 'dev' of www.gitinn.com:proginn/proginn-frontend into dev 6 years ago
  xiaozhen 503028341b 修复注册缺少消息提示 6 years ago
  wayne a294dbe04f 修复bug 6 years ago
4 changed files with 312 additions and 215 deletions
  1. 208 168
      pages/salary/_id.vue
  2. 102 40
      pages/salary/index.vue
  3. 1 6
      pages/user/register.vue
  4. 1 1
      plugins/nuxtAxios.js

+ 208 - 168
pages/salary/_id.vue

@@ -56,15 +56,15 @@
     <div class="wrapper mobile" v-else-if="screenWidth > 0">
       <div class="title-wrapper">
         <div class="title">{{city}}-{{job}}收入水平</div>
-        <div class="subtitle">杭州产品经理平均工资:¥66666/月,统计来自程序员客栈(proginn.com)</div>
+        <div class="subtitle">{{city}}{{job}}平均工资:¥{{avg_salary}}/月,统计来自程序员客栈(proginn.com)</div>
       </div>
       <div class="module-wrapper">
         <div class="module-title">开发者薪资排行城市TOP10</div>
         <div id="range-chart" class="range-chart"></div>
       </div>
       <div class="module-wrapper">
-        <div class="average-title">平均工资:¥13000元/月</div>
-        <div class="average-subtitle">最高为16000元/月,最低为10000元/月,其中,人工智能行业的产品经理平均工资最高达54363元/月</div>
+        <div class="average-title">平均工资:¥{{avg_salary}}元/月</div>
+        <div class="average-subtitle">最高为{{max_salary}}元/月,最低为{{min_salary}}元/月,其中,人工智能行业的产品经理平均工资最高达{{avg_salary}}元/月</div>
         <img class="average-img" src="@/assets/img/salary/average_salary.png" alt />
       </div>
       <!--      <div class="module-wrapper">-->
@@ -108,180 +108,220 @@
 </template>
 
 <script>
-  export default {
-    head() {
-      return {
-        title: `${this.city}${this.job}月薪工资待遇查询,【城市】企业招聘【岗位】费用查询-程序员客栈`,
-        meta: [
-            {
-                name: "keywords",
-                content: `${this.city}${this.job}工资, ${this.city}${this.job}兼职工资, ${this.city}企业${this.job}招聘费用`
-            },
-            {
-                name: "descrption",
-                content: `程序员客栈提供${this.city}${this.job}工资查询,让${this.city}${this.job}程序员能了解自身兼职价值,帮助${this.city}有${this.job}招聘需求的企业利用合理的费用找到合适的人才!`
-            }
-        ]
+export default {
+  head() {
+    return {
+      title: `${this.city}${this.job}月薪工资待遇查询,${this.city}企业招聘${this.job}费用查询-程序员客栈`,
+      meta: [
+        {
+          name: "keywords",
+          content: `${this.city}${this.job}工资,${this.city}${this.job}兼职工资,${this.city}企业${this.job}招聘费用`
+        },
+        {
+          name: "descrption",
+          content: `程序员客栈提供${this.city}${this.job}工资查询,让${this.city}${this.job}程序员能了解自身兼职价值,帮助${this.city}有${this.job}招聘需求的企业利用合理的费用找到合适的人才!`
+        }
+      ]
+    };
+  },
+  async asyncData ({ $axios, req, res }) {
+    // 请检查您是否在服务器端
+    // 使用 req 和 res
+    console.log(req)
+    if (process.server) {
+      const path = req.url
+      const cityJob = path.split('/')[2]
+      const city = cityJob.split('-')[0]
+      const job = cityJob.split('-')[1].replace('c%23', 'c#')
+      let params = {
+        job: job,
+        city: city
       };
-    },
-    data() {
+      let res = await $axios.$post("/api/salary/search_info", params);
+
+      const jobList = res.data.jobSort || [];
+      const experience = res.data.experience || [];
+
+
+      for (let i = 0; i < jobList.length; i++) {
+        jobList[i].salary = parseInt(jobList[i].salary);
+      }
+      for (let i = 0; i < experience.length; i++) {
+        experience[i].salary = parseInt(experience[i].salary);
+      }
       return {
-        screenWidth: 0,
-        job: "",
-        city: "",
-        avg_salary: 0,
-        max_salary: 0,
-        min_salary: 0,
-        jobList: [],
-        experience: [],
-        allCitySalary: [],
-        salaryRange: []
-      };
-    },
-    mounted() {
-      this.screenWidth = window.screen.width;
-      this.$nextTick(() => {
-        this.getData();
-        // this.getRangeChart();
-        // this.getIndustryChart();
-        // this.getExperienceChart();
-        // this.getEducationChart()
-        // this.getCityChart()
-      });
-    },
-    methods: {
-      async getData() {
-        const path = window.location.pathname
-        const cityJob = path.split('/')[2]
-        this.city = cityJob.split('-')[0]
-        this.job = cityJob.split('-')[1]
-        let params = {
-          job: this.job,
-          city: this.city
-        };
-        let res = await this.$axios.$post("/api/salary/search_info", params);
-        this.job = res.data.info.job;
-        this.city = res.data.info.city;
-        this.avg_salary = res.data.info.avg_salary;
-        this.max_salary = res.data.info.max_salary;
-        this.min_salary = res.data.info.min_salary;
-        this.jobList = res.data.jobSort || [];
-        this.experience = res.data.experience || [];
-        this.allCitySalary = res.data.allCitySalary || [];
-        this.salaryRange = res.data.salaryRange || [];
+        job: res.data.info.job,
+        city: res.data.info.city,
+        avg_salary: res.data.info.avg_salary,
+        max_salary: res.data.info.max_salary,
+        min_salary: res.data.info.min_salary,
+        jobList: jobList,
+        experience: experience,
+        allCitySalary: res.data.allCitySalary || [],
+        salaryRange: res.data.salaryRange || [],
+      }
+    }
 
-        for (let i = 0; i < this.jobList.length; i++) {
-          this.jobList[i].salary = parseInt(this.jobList[i].salary);
-        }
-        for (let i = 0; i < this.experience.length; i++) {
-          this.experience[i].salary = parseInt(this.experience[i].salary);
+    return {}
+  },
+  data() {
+    return {
+      screenWidth: 0,
+      job: "",
+      city: "",
+      avg_salary: 0,
+      max_salary: 0,
+      min_salary: 0,
+      jobList: [],
+      experience: [],
+      allCitySalary: [],
+      salaryRange: []
+    };
+  },
+  mounted() {
+    this.screenWidth = window.screen.width;
+    this.$nextTick(() => {
+      this.getData();
+      // this.getRangeChart();
+      // this.getIndustryChart();
+      // this.getExperienceChart();
+      // this.getEducationChart()
+      // this.getCityChart()
+    });
+  },
+  methods: {
+    async getData() {
+      // const path = window.location.pathname
+      // const cityJob = path.split('/')[2]
+      // this.city = cityJob.split('-')[0]
+      // this.job = cityJob.split('-')[1]
+      // let params = {
+      //   job: this.job,
+      //   city: this.city
+      // };
+      // let res = await this.$axios.$post("/api/salary/search_info", params);
+      // this.job = res.data.info.job;
+      // this.city = res.data.info.city;
+      // this.avg_salary = res.data.info.avg_salary;
+      // this.max_salary = res.data.info.max_salary;
+      // this.min_salary = res.data.info.min_salary;
+      // this.jobList = res.data.jobSort || [];
+      // this.experience = res.data.experience || [];
+      // this.allCitySalary = res.data.allCitySalary || [];
+      // this.salaryRange = res.data.salaryRange || [];
+
+      // for (let i = 0; i < this.jobList.length; i++) {
+      //   this.jobList[i].salary = parseInt(this.jobList[i].salary);
+      // }
+      // for (let i = 0; i < this.experience.length; i++) {
+      //   this.experience[i].salary = parseInt(this.experience[i].salary);
+      // }
+      const sortJob = this.jobList;
+      const sortExperience = this.experience;
+      const allSalaryRange = this.salaryRange;
+      const chart = new G2.Chart({
+        container: "range-chart",
+        forceFit: true,
+        height: 300
+      });
+      chart.source(allSalaryRange, {
+        percent: {
+          formatter: function formatter(val) {
+            val = val * 100 + "%";
+            return val;
+          }
         }
-        const sortJob = this.jobList;
-        const sortExperience = this.experience;
-        const allSalaryRange = this.salaryRange;
-        const chart = new G2.Chart({
-          container: "range-chart",
-          forceFit: true,
-          height: 300
-        });
-        chart.source(allSalaryRange, {
-          percent: {
-            formatter: function formatter(val) {
-              val = val * 100 + "%";
-              return val;
+      });
+      chart.coord("theta", {
+          radius: 0.75
+      });
+      chart.tooltip({
+        showTitle: false,
+        itemTpl:
+            '<li><span style="background-color:{color};" class="g2-tooltip-marker"></span>{name}: {value}</li>'
+      });
+      chart
+        .intervalStack()
+        .position("percent")
+        .color("item")
+        .label("percent", {
+            formatter: function formatter(val, item) {
+                return item.point.item + ": " + val;
             }
-          }
-        });
-        chart.coord("theta", {
-            radius: 0.75
+        })
+        .tooltip("item*percent", function(item, percent) {
+            percent = percent * 100 + "%";
+            return {
+                name: item,
+                value: percent
+            };
+        })
+        .style({
+            lineWidth: 1,
+            stroke: "#fff"
         });
-        chart.tooltip({
-          showTitle: false,
-          itemTpl:
-              '<li><span style="background-color:{color};" class="g2-tooltip-marker"></span>{name}: {value}</li>'
-        });
-        chart
-          .intervalStack()
-          .position("percent")
-          .color("item")
-          .label("percent", {
-              formatter: function formatter(val, item) {
-                  return item.point.item + ": " + val;
-              }
-          })
-          .tooltip("item*percent", function(item, percent) {
-              percent = percent * 100 + "%";
-              return {
-                  name: item,
-                  value: percent
-              };
-          })
-          .style({
-              lineWidth: 1,
-              stroke: "#fff"
-          });
-        chart.render();
+      chart.render();
 
-        // const chart1 = new G2.Chart({
-        //   container: "industry-chart",
-        //   forceFit: true,
-        //   height: 300
-        // });
-        // chart1.source(sortJob);
-        // chart1.scale("salary", {
-        //   min: 0
-        // });
-        // chart1.scale("job", {
-        //   range: [0, 1]
-        // });
-        // chart1.tooltip({
-        //   crosshairs: {
-        //     type: "line"
-        //   }
-        // });
-        // chart1.line().position("job*salary");
-        // chart1
-        //   .point()
-        //   .position("job*salary")
-        //   .size(4)
-        //   .shape("circle")
-        //   .style({
-        //     stroke: "#fff",
-        //     lineWidth: 1
-        //   });
-        // chart1.render();
+      // const chart1 = new G2.Chart({
+      //   container: "industry-chart",
+      //   forceFit: true,
+      //   height: 300
+      // });
+      // chart1.source(sortJob);
+      // chart1.scale("salary", {
+      //   min: 0
+      // });
+      // chart1.scale("job", {
+      //   range: [0, 1]
+      // });
+      // chart1.tooltip({
+      //   crosshairs: {
+      //     type: "line"
+      //   }
+      // });
+      // chart1.line().position("job*salary");
+      // chart1
+      //   .point()
+      //   .position("job*salary")
+      //   .size(4)
+      //   .shape("circle")
+      //   .style({
+      //     stroke: "#fff",
+      //     lineWidth: 1
+      //   });
+      // chart1.render();
 
-        // const chart2 = new G2.Chart({
-        //   container: "experience-chart",
-        //   forceFit: true,
-        //   height: 300
-        // });
-        // chart2.source(sortExperience);
-        // chart2.scale("salary", {
-        //   min: 0
-        // });
-        // chart2.scale("experience", {
-        //   range: [0, 1]
-        // });
-        // chart2.tooltip({
-        //   crosshairs: {
-        //     type: "line"
-        //   }
-        // });
-        // chart2.line().position("experience*salary");
-        // chart2
-        //   .point()
-        //   .position("experience*salary")
-        //   .size(4)
-        //   .shape("circle")
-        //   .style({
-        //     stroke: "#fff",
-        //     lineWidth: 1
-        //   });
-        // chart2.render();
-      }
+      // const chart2 = new G2.Chart({
+      //   container: "experience-chart",
+      //   forceFit: true,
+      //   height: 300
+      // });
+      // chart2.source(sortExperience);
+      // chart2.scale("salary", {
+      //   min: 0
+      // });
+      // chart2.scale("experience", {
+      //   range: [0, 1]
+      // });
+      // chart2.tooltip({
+      //   crosshairs: {
+      //     type: "line"
+      //   }
+      // });
+      // chart2.line().position("experience*salary");
+      // chart2
+      //   .point()
+      //   .position("experience*salary")
+      //   .size(4)
+      //   .shape("circle")
+      //   .style({
+      //     stroke: "#fff",
+      //     lineWidth: 1
+      //   });
+      // chart2.render();
     }
-  };
+  }
+};
 </script>
 
 <style lang="scss" scoped>

+ 102 - 40
pages/salary/index.vue

@@ -4,7 +4,7 @@
       <div class="header">
         <h1 class="title">查岗位薪资 就上程序员客栈</h1>
         <div class="search-wrapper">
-          <el-select @change="changeJob" v-model="searchJob" placeholder="请选择">
+          <el-select class="salary-job-search" style="margin-right:5px;width:500px;" @change="changeJob" v-model="searchJob" placeholder="请选择">
             <el-option
               v-for="item in jobList"
               :key="item.job"
@@ -13,7 +13,7 @@
             ></el-option>
           </el-select>
 
-          <el-select style="margin: 10px;width:100px;" v-model="searchCity" placeholder="请选择">
+          <el-select class="salary-city-search" style="margin-right:5px;width:100px;" v-model="searchCity" placeholder="请选择">
             <el-option
               v-for="item in cityList"
               :key="item.city"
@@ -22,7 +22,7 @@
             ></el-option>
           </el-select>
 
-          <el-button style="background-color: #147eff;" @click="search" type="primary">查询</el-button>
+          <div class="search-btn" @click="search" type="primary">查询</div>
 
           <!--          <div class="search-content">-->
           <!--            <input type="text" @keyup.enter="search" v-model="searchJob" placeholder="请输入您需要查询的岗位名称,如c++软件工程师" class="search-input">-->
@@ -46,7 +46,7 @@
       <div class="content">
         <div
           class="info"
-        >截至2019年9月6日,调查了全国的开发者的工资数据后发现,{{city}}开发者平均工资最高达¥{{citySalary}}元/月,{{job}}开发者的平均工资最高达{{jobSalary}}元/月,本数据仅供参考。</div>
+        >截至2019年9月6日,调查了全国的开发者的工资数据后发现,{{searchCity}}开发者平均工资最高达¥{{citySalary}}元/月,{{searchJob}}开发者的平均工资最高达{{jobSalary}}元/月,本数据仅供参考。</div>
         <div class="module-wrapper">
           <div class="module-title">开发者薪资排行城市TOP10</div>
           <div id="city-chart" class="city-chart"></div>
@@ -64,20 +64,25 @@
           <br />就上程序员客栈
         </div>
         <div class="search-wrapper">
-          <el-select @change="changeJob" v-model="searchJob" placeholder="请选择">
-            <el-option v-for="item in jobList" :key="item.job" :label="item.job" :value="item.job"></el-option>
+          <el-select class="salary-job-search" style="margin-right:.1rem;width:3.75rem;" @change="changeJob" v-model="searchJob" placeholder="请选择">
+            <el-option
+              v-for="item in jobList"
+              :key="item.job"
+              :label="item.job"
+              :value="item.job_slug"
+            ></el-option>
           </el-select>
 
-          <el-select style="margin: 3px;width:100px;" v-model="searchCity" placeholder="请选择">
+          <el-select class="salary-city-search" style="margin-right:.1rem;width:2rem;" v-model="searchCity" placeholder="请选择">
             <el-option
               v-for="item in cityList"
               :key="item.city"
               :label="item.city"
-              :value="item.city"
+              :value="item.city_slug"
             ></el-option>
           </el-select>
 
-          <el-button style="background-color: #147eff;" @click="search" type="primary">查询</el-button>
+          <div class="search-btn" @click="search" type="primary">查询</div>
 
           <!--          <div class="search-content">-->
           <!--            <input type="text" @keyup.enter="search" v-model="searchJob" placeholder="岗位名称,如c++软件工程师" class="search-input">-->
@@ -98,7 +103,7 @@
       <div class="content">
         <div
           class="info"
-        >截至2019年9月6日,调查了全国38749756名开发者的工资数据后发现,上海开发者平均工资最高达¥97974元/月,Python开发者的平均工资最高达66666元/月,本数据仅供参考。</div>
+        >截至2019年9月6日,调查了全国的开发者的工资数据后发现,{{searchCity}}开发者平均工资最高达¥{{citySalary}}元/月,{{searchJob}}开发者的平均工资最高达{{jobSalary}}元/月,本数据仅供参考。</div>
         <div class="module-wrapper">
           <div class="module-title">开发者薪资排行城市TOP10</div>
           <div id="city-chart" class="city-chart"></div>
@@ -147,6 +152,49 @@ export default {
       searchCity: ""
     };
   },
+  async asyncData ({ $axios, req, res }) {
+    // 请检查您是否在服务器端
+    // 使用 req 和 res
+    console.log(req)
+    if (process.server) {
+      let res = await $axios.$post("/api/salary/index_info");
+      const cityChart = res.data.sortOfCity;
+      const jobChart = res.data.sortOfJob;
+      const jobList = res.data.allJobType;
+      const city = res.data.sortOfCity[0].city;
+      const citySalary = res.data.sortOfCity[0].salary;
+      const job = res.data.sortOfJob[0].job;
+      const jobSalary = res.data.sortOfJob[0].salary;
+      const cityTick = res.data.cityTick;
+      const jobTick = res.data.jobTick;
+      const cityList = res.data.cityList;
+      const searchJob = res.data.allJobType[0].job_slug;
+      const searchCity = res.data.cityList[0].city_slug;
+
+      for (let i = 0; i < cityChart.length; i++) {
+        cityChart[i].salary = parseInt(cityChart[i].salary);
+      }
+      for (let i = 0; i < jobChart.length; i++) {
+        jobChart[i].salary = parseInt(jobChart[i].salary);
+      }
+      return {
+        cityChart,
+        jobChart,
+        jobList,
+        city,
+        citySalary,
+        cityList,
+        job,
+        jobSalary,
+        cityTick,
+        jobTick,
+        searchJob,
+        searchCity
+      }
+    }
+
+    return {}
+  },
   mounted() {
     this.screenWidth = window.screen.width;
     this.$nextTick(() => {
@@ -155,29 +203,29 @@ export default {
   },
   methods: {
     async getData() {
-      let res = await this.$axios.$post("/api/salary/index_info");
-
-      this.cityChart = res.data.sortOfCity;
-      this.jobChart = res.data.sortOfJob;
-      this.jobList = res.data.allJobType;
-      this.city = res.data.sortOfCity[0].city;
-      this.citySalary = res.data.sortOfCity[0].salary;
-      this.job = res.data.sortOfJob[0].job;
-      this.jobSalary = res.data.sortOfJob[0].salary;
-      this.cityTick = res.data.cityTick;
-      this.jobTick = res.data.jobTick;
-      this.cityList = res.data.cityList;
-      this.searchJob = res.data.allJobType[0].job_slug;
-      this.searchCity = res.data.cityList[0].city_slug;
-
-      console.log(this.cityList);
-
-      for (let i = 0; i < this.cityChart.length; i++) {
-        this.cityChart[i].salary = parseInt(this.cityChart[i].salary);
-      }
-      for (let i = 0; i < this.jobChart.length; i++) {
-        this.jobChart[i].salary = parseInt(this.jobChart[i].salary);
-      }
+      // let res = await this.$axios.$post("/api/salary/index_info");
+
+      // this.cityChart = res.data.sortOfCity;
+      // this.jobChart = res.data.sortOfJob;
+      // this.jobList = res.data.allJobType;
+      // this.city = res.data.sortOfCity[0].city;
+      // this.citySalary = res.data.sortOfCity[0].salary;
+      // this.job = res.data.sortOfJob[0].job;
+      // this.jobSalary = res.data.sortOfJob[0].salary;
+      // this.cityTick = res.data.cityTick;
+      // this.jobTick = res.data.jobTick;
+      // this.cityList = res.data.cityList;
+      // this.searchJob = res.data.allJobType[0].job_slug;
+      // this.searchCity = res.data.cityList[0].city_slug;
+
+      // console.log(this.cityList);
+
+      // for (let i = 0; i < this.cityChart.length; i++) {
+      //   this.cityChart[i].salary = parseInt(this.cityChart[i].salary);
+      // }
+      // for (let i = 0; i < this.jobChart.length; i++) {
+      //   this.jobChart[i].salary = parseInt(this.jobChart[i].salary);
+      // }
 
       //开发者薪资排行城市TOP10
       const chart1 = new G2.Chart({
@@ -220,14 +268,12 @@ export default {
         this.$message("请输入查询岗位名称");
         return false;
       }
-      this.searchJob = this.searchJob.replace(/c#/, "c%23");
-      this.searchJob = this.searchJob.replace(/c\+\+*/, "c%24");
+      // this.searchJob = this.searchJob.replace(/c#/, "c%23");
+      // this.searchJob = this.searchJob.replace(/c\+\+*/, "c%24");
       // this.$router.push(
       //   "/salary/detail?job=" + this.searchJob + "&city=" + this.searchCity
       // );
-      this.$router.push(
-        `/salary/${this.searchCity}-${this.searchJob}/`
-      );
+      window.location.href = `/salary/${this.searchCity}-${this.searchJob}/`.replace('c#', 'c%23');
     },
     inVal(val) {
       this.searchJob = val;
@@ -312,7 +358,7 @@ export default {
   .search-btn {
     width: 104px;
     height: 53px;
-    border-radius: 0px 4px 4px 0px;
+    border-radius: 4px;
     background-color: #147eff;
     line-height: 53px;
     text-align: center;
@@ -490,7 +536,8 @@ export default {
 
   .city-chart,
   .job-chart {
-    margin: 0.48rem auto 0;
+    margin-top: 0.48rem;
+    margin-left: -0.24rem;
     width: 100%;
   }
 
@@ -511,3 +558,18 @@ export default {
   }
 }
 </style>
+
+<style>
+  .pc .salary-job-search .el-input__inner {
+    height: 53px;
+  }
+  .pc .salary-city-search .el-input__inner {
+    height: 53px;
+  }
+  .mobile .salary-job-search .el-input__inner {
+    height: .85rem;
+  }
+  .mobile .salary-city-search .el-input__inner {
+    height: .85rem;
+  }
+</style>

+ 1 - 6
pages/user/register.vue

@@ -194,7 +194,7 @@ export default {
       let register = async body => {
         let res = await this.$axios.$post("/api/passport/register", body);
         if (res && res.data) {
-          this.$message(res.data.info);
+          this.$message.success(res.info);
           setTimeout(() => {
             location.href = "/user/success";
           }, 1000);
@@ -212,7 +212,6 @@ export default {
             };
             register(body);
           } else {
-            console.log("error submit!!");
             return false;
           }
         });
@@ -227,7 +226,6 @@ export default {
             };
             register(body);
           } else {
-            console.log("error submit!!");
             return false;
           }
         });
@@ -259,8 +257,6 @@ export default {
         appId: "2db960e4ca0eaeee12ef63db7e5b3918", //appId,在控制台中“应用管理”或“应用配置”模块获取
         style: "popup",
         success: async function(token) {
-          console.log("token:", token);
-          //console.log(area + mobile)
           let res = await that.$axios.$post("/api/user/sendMobileAuthCode", {
             mobile: area + "-" + mobile,
             token,
@@ -268,7 +264,6 @@ export default {
           });
           if (res) {
             run();
-            // this.$message(res.info);
             myCaptcha.hide();
           }
         }

+ 1 - 1
plugins/nuxtAxios.js

@@ -9,7 +9,7 @@ export default function({ $axios, redirect, req, ...args }) {
 			config.headers['Content-Type'] = 'application/x-www-form-urlencoded';
 		}
 		console.log('Before, making request to ', config.url, config.baseURL);
-		const referer = config.headers.host || (config.headers.common && config.headers.common.referer);
+		const referer = (req && req.headers && req.headers.host) || (config.headers.common && config.headers.common.referer);
 		const baseUrl = /https?/.test(referer) ? referer : 'https://' + referer;
 		const url = config.url;
 		// if (referer && !(/https?/.test(url))) {