valasek/timesheet

View on GitHub
client/src/api/axiosSettings.js

Summary

Maintainability
A
0 mins
Test Coverage
// Copyright © 2018-2020 Stanislav Valasek <valasek@gmail.com>

import axios from 'axios'

var baseURL = 'http://' + process.env.APP_DOMAIN + ':' + process.env.APP_PORT

// const debug = !process.env.NODE_ENV.startsWith('production')
// if (debug) {
//   baseURL = 'http://localhost:3000'
// }

const apiClient = axios.create({
  baseURL: baseURL,
  withCredentials: false, // This is the default
  crossDomain: true,
  headers: {
    Accept: 'application/json',
    'Content-Type': 'application/json'
    // 'Accept-Encoding': 'gzip, deflate, br'
  },
  timeout: 10000
})

// apiClient.interceptors.response.use(function (response) {
//   var ctype = response.headers['content-type']
//   response.data = ctype.includes('charset=GB2312') ? iconv.decode(response.data, 'gb2312') : iconv.decode(response.data, 'utf-8')
//   return response
// })

export default {
  apiClient
}