From 733c1bc9cb59504fe9dca5332e040a7f9a596a70 Mon Sep 17 00:00:00 2001 From: Ajan Lal Shrestha Date: Sun, 22 Dec 2019 18:44:35 +0545 Subject: [PATCH] refactor: Change the API to api/jobs - Add proxy to API server --- api/index.js | 2 +- client/package.json | 3 ++- client/src/App.js | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/api/index.js b/api/index.js index 5f7f93d..fdf3bc2 100644 --- a/api/index.js +++ b/api/index.js @@ -17,7 +17,7 @@ app.use(function(req, res, next) { }); app.get('/', (req, res) => res.send('Jobs API!')); -app.get('/jobs', async (req, res) => { +app.get('/api/jobs', async (req, res) => { const jobs = await getAsync('github'); return res.send(jobs); }); diff --git a/client/package.json b/client/package.json index 5a69a79..8e7f12c 100644 --- a/client/package.json +++ b/client/package.json @@ -21,6 +21,7 @@ "eslintConfig": { "extends": "react-app" }, + "proxy": "http://localhost:5000", "browserslist": { "production": [ ">0.2%", @@ -33,4 +34,4 @@ "last 1 safari version" ] } -} +} \ No newline at end of file diff --git a/client/src/App.js b/client/src/App.js index 7ad9c70..4f30d81 100644 --- a/client/src/App.js +++ b/client/src/App.js @@ -3,7 +3,7 @@ import './App.css'; import Jobs from './Jobs'; -const JOB_API_URL = 'http://localhost:5000/jobs'; +const JOB_API_URL = '/api/jobs'; const fetchJobs = async updateCb => { const res = await fetch(JOB_API_URL);