Skip to content

Commit ae8bf8b

Browse files
committed
fix: proxy now correctly works
1 parent 09c59fc commit ae8bf8b

File tree

8 files changed

+27
-19
lines changed

8 files changed

+27
-19
lines changed

client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@
139139
"stylelint-order": "^2.0.0",
140140
"stylelint-selector-no-empty": "^1.0.7"
141141
},
142-
"proxy": "http://localhost:5000/api",
142+
"proxy": "http://localhost:5000",
143143
"browserslist": [
144144
">0.2%",
145145
"not dead",

client/src/containers/GenericPage/Authors/AuthorPage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class AuthorPage extends Component {
2828
const { match } = this.props
2929

3030
axios
31-
.get(`${match.url}`)
31+
.get(`/api${match.url}`)
3232
.then(({ data }) => {
3333
this.setState({
3434
data,

client/src/containers/GenericPage/Conferences/ConferencePage.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class ConferencesPage extends Component {
3131
const { match } = this.props
3232

3333
axios
34-
.get(`${match.url}`)
34+
.get(`/api${match.url}`)
3535
.then(({ data }) => {
3636
this.setState({
3737
data,
@@ -45,7 +45,7 @@ class ConferencesPage extends Component {
4545
})
4646

4747
axios
48-
.get(`${match.url}/documents`)
48+
.get(`/api${match.url}/documents`)
4949
.then(({ data: documents }) => {
5050
this.setState({
5151
documents,
@@ -59,7 +59,7 @@ class ConferencesPage extends Component {
5959
})
6060

6161
axios
62-
.get(`${match.url}/sponsors`)
62+
.get(`/api${match.url}/sponsors`)
6363
.then(({ data: sponsors }) => {
6464
this.setState({
6565
sponsors,
@@ -73,7 +73,7 @@ class ConferencesPage extends Component {
7373
})
7474

7575
axios
76-
.get(`${match.url}/organizations`)
76+
.get(`/api${match.url}/organizations`)
7777
.then(({ data: organizations }) => {
7878
this.setState({
7979
organizations,

client/src/containers/GenericPage/Documents/DocumentPage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class AuthorPage extends Component {
2727
const { match } = this.props
2828

2929
axios
30-
.get(`${match.url}`)
30+
.get(`/api${match.url}`)
3131
.then(({ data }) => {
3232
this.setState({
3333
data,

client/src/containers/GenericPage/Organizations/OrganizationPage.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class AuthorPage extends Component {
2424
const { match } = this.props
2525

2626
axios
27-
.get(`${match.url}`)
27+
.get(`/api${match.url}`)
2828
.then(({ data }) => {
2929
this.setState({
3030
data,
@@ -38,7 +38,7 @@ class AuthorPage extends Component {
3838
})
3939

4040
axios
41-
.get(`${match.url}/authors`)
41+
.get(`/api${match.url}/authors`)
4242
.then(({ data: authors }) => {
4343
this.setState({
4444
authors,
@@ -49,7 +49,7 @@ class AuthorPage extends Component {
4949
})
5050

5151
axios
52-
.get(`${match.url}/conferences`)
52+
.get(`/api${match.url}/conferences`)
5353
.then(({ data: conferences }) => {
5454
this.setState({
5555
conferences,

client/src/containers/GenericPage/Periodicals/PeriodicalPage.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class PeriodicalPage extends Component {
2222
const { match } = this.props
2323

2424
axios
25-
.get(`${match.url}`)
25+
.get(`/api${match.url}`)
2626
.then(({ data }) => {
2727
this.setState({
2828
data,
@@ -36,7 +36,7 @@ class PeriodicalPage extends Component {
3636
})
3737

3838
axios
39-
.get(`${match.url}/numbers`)
39+
.get(`/api${match.url}/numbers`)
4040
.then(({ data: numbers }) => {
4141
this.setState({
4242
numbers,

client/src/containers/GenericPage/PublishingCompanies/PublishingCompanyPage.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class AuthorPage extends Component {
2222
const { match } = this.props
2323

2424
axios
25-
.get(`${match.url}`)
25+
.get(`/api${match.url}`)
2626
.then(({ data }) => {
2727
this.setState({
2828
data,
@@ -36,7 +36,7 @@ class AuthorPage extends Component {
3636
})
3737

3838
axios
39-
.get(`${match.url}/periodicals`)
39+
.get(`/api${match.url}/periodicals`)
4040
.then(({ data: periodicals }) => {
4141
this.setState({
4242
periodicals,

client/src/containers/ResultsPage/ResultsPage.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { Component, lazy, Suspense } from 'react'
22
import axios from 'axios'
33
import Spinner from 'components/Spinner'
44
import Banner from 'components/Banner'
5-
import { withRouter } from 'react-router-dom'
5+
import { withRouter, Redirect } from 'react-router-dom'
66

77
const AuthorsTable = lazy(() => import('components/AuthorsTable'))
88
const ConferencesTable = lazy(() => import('components/ConferencesTable'))
@@ -14,25 +14,29 @@ const OrganizationsTable = lazy(() => import('components/OrganizationsTable'))
1414
class Results extends Component {
1515
state = {
1616
data: null,
17+
error: false,
1718
}
1819

1920
componentDidMount() {
2021
const { match } = this.props
2122

2223
axios
23-
.get(`${match.path}`)
24+
.get(`/api${match.url}`)
2425
.then(({ data }) => {
2526
this.setState({
2627
data,
28+
error: typeof data === 'string',
2729
})
2830
})
29-
.catch(err => {
30-
console.log(err)
31+
.catch(() => {
32+
this.setState({
33+
error: true,
34+
})
3135
})
3236
}
3337

3438
render() {
35-
const { data } = this.state
39+
const { data, error } = this.state
3640
const {
3741
location: { pathname, search },
3842
} = this.props
@@ -53,6 +57,10 @@ class Results extends Component {
5357
text = (data && `${data.length} ${collection} found`) || `Searching ${collection}...`
5458
}
5559

60+
if (error) {
61+
return <Redirect to={`/${collection}/error`} />
62+
}
63+
5664
return (
5765
<>
5866
<Banner text={text} />

0 commit comments

Comments
 (0)