Skip to content

Commit a08189f

Browse files
committed
Setup API HOST envvar
1 parent fb52c85 commit a08189f

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

.env

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
HTTPS=true
1+
HTTPS=true
2+
REACT_APP_API_HOST=https://v2.velog.io/

src/lib/api/apiClient.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import axios from 'axios';
22

3-
const apiClient = axios.create();
3+
const host =
4+
process.env.NODE_ENV === 'development'
5+
? '/'
6+
: process.env.REACT_APP_API_HOST || '/';
7+
const apiClient = axios.create({
8+
baseURL: host,
9+
});
410

511
export default apiClient;

src/lib/graphql/client.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
import ApolloClient from 'apollo-boost';
22
import { InMemoryCache } from 'apollo-cache-inmemory';
33

4+
const host =
5+
(process.env.NODE_ENV === 'development'
6+
? '/'
7+
: process.env.REACT_APP_API_HOST) || '/';
8+
9+
const graphqlURI = host.concat('graphql');
10+
411
const client = new ApolloClient({
5-
uri: '/graphql',
12+
uri: graphqlURI,
613
cache: new InMemoryCache().restore((window as any).__APOLLO_STATE__),
714
});
815

0 commit comments

Comments
 (0)