set api with REACT_APP_API

This commit is contained in:
data 2019-06-22 05:58:15 -04:00 committed by notnull
parent 1222e7794c
commit 274ca42e7a
2 changed files with 6 additions and 7 deletions

View File

@ -3,6 +3,10 @@ import axios from 'axios'
import { About, Tasks, Profile, Projects, Project, Navbar } from './components'
const api = process.env.REACT_APP_API || 'http://localhost:1337'
//console.log(process.env)
console.log('Using api at ' + api)
const defaultState = {
user: { name: 'Scott' },
loading: true,
@ -32,13 +36,13 @@ class App extends React.Component {
async fetchTasks() {
console.log('Fetching tasks...')
const { data } = await axios.get('/api/tasks')
const { data } = await axios.get(api + '/api/tasks')
await this.setState({ tasks: data })
}
async fetchProjects() {
console.log('Fetching projects...')
const { data } = await axios.get('/api/projects')
const { data } = await axios.get(api + '/api/projects')
await this.setState({ projects: data })
}

View File

@ -1,5 +0,0 @@
const proxy = require('http-proxy-middleware')
module.exports = function(app) {
app.use(proxy('/api', { target: 'http://localhost:1337/' }))
}