Skip to content

Commit

Permalink
(#827) make react app request to separate api host
Browse files Browse the repository at this point in the history
  • Loading branch information
kimjson committed Sep 12, 2021
1 parent 5cdb0d4 commit 848d176
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
3 changes: 1 addition & 2 deletions react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,5 @@
"eslint-plugin-jsx-a11y": "^6.3.1",
"eslint-plugin-no-loops": "^0.3.0",
"eslint-plugin-react": "^7.20.6"
},
"proxy": "http://localhost:8000"
}
}
1 change: 1 addition & 0 deletions react/src/common/apiBaseUrl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default process.env.NODE_ENV === 'production' ? 'https://api.otl.kaist.ac.kr' : 'http://localhost:8000';
3 changes: 2 additions & 1 deletion react/src/common/guideline/components/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import PropTypes from 'prop-types';
import { withTranslation } from 'react-i18next';

import { guidelineBoundClassNames as classNames, appBoundClassNames } from '../../boundClassNames';
import API_BASE_URL from '../../apiBaseUrl';

import userShape from '../../../shapes/UserShape';

Expand Down Expand Up @@ -167,7 +168,7 @@ class Header extends Component {
)
: (

<a href={`/session/login/?next=${window.location.href}`}>
<a href={`${API_BASE_URL}/session/login/?next=${window.location.href}`}>
<i className={classNames('icon--header_user')} />
<span>
{t('ui.menu.signIn')}
Expand Down
4 changes: 3 additions & 1 deletion react/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,13 @@ i18n

import axios from 'axios';
import Qs from 'qs';
import API_BASE_URL from './common/apiBaseUrl';

axios.defaults.xsrfHeaderName = 'X-CSRFToken';
axios.defaults.xsrfCookieName = 'csrftoken';

axios.defaults.baseURL = '/';
axios.defaults.baseURL = API_BASE_URL;
axios.defaults.withCredentials = true;

axios.defaults.paramsSerializer = (params) => Qs.stringify(params, { arrayFormat: 'repeat' });

Expand Down

0 comments on commit 848d176

Please sign in to comment.