Skip to content

Commit

Permalink
update server endpoint for dev and production
Browse files Browse the repository at this point in the history
  • Loading branch information
TimZeng committed Oct 12, 2017
1 parent 581fc21 commit c558367
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/components/PDFDisplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class PDFDisplay extends Component {
data.append('name', 'file name');
data.append('description', 'description of the file');

axios.post('/file', data)
axios.post(`${this.props.endpoint}/file`, data)
.then(response => {
if (response.status === 200) {
window.alert('File upload success!');
Expand Down Expand Up @@ -189,7 +189,7 @@ class PDFDisplay extends Component {
const { file } = this.state;
const context = this;
if ( !!x && !!y && !!width && !!height && !!color ) {
axios.post('/edit', {...this.state.params, file: file.slice(2)})
axios.post(`${this.props.endpoint}/edit`, {...this.state.params, file: file.slice(2)})
.then((response) => {
if (response.status === 200) {
console.error('response>>>>>>');
Expand Down
2 changes: 1 addition & 1 deletion src/components/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default class App extends Component {
<div style={{backgroundColor:'grey'}}>
<center className='container'>
<h1>PDF Editor</h1>
<PDFDisplay />
<PDFDisplay endpoint={this.props.endpoint} />
</center>
</div>
);
Expand Down
10 changes: 9 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,12 @@ import ReactDOM from 'react-dom';

import App from './components/app';

ReactDOM.render(<App />, document.querySelector('.app'));
// Setup server endpoint
const isDev = window.location.hostname === 'localhost';
const devServer = 'https://localhost:3000';
const prodServer = '';

ReactDOM.render(
<App endpoint={isDev ? devServer : prodServer} />,
document.querySelector('.app')
);

0 comments on commit c558367

Please sign in to comment.