Привет, я использую реагирующий маршрутизатор v4.
My React работает на порту 3000, а экспресс-сервер работает на порту 8080. Сегмент Redirect приведенного ниже кода приводит меня к localhost:3000/http://localhost:8080/auth/login
.
У меня есть "proxy": "localhost:8080"
в пакете моего React.json.Это не работает.
Как я могу перенаправить с localhost:3000
на localhost:8080/auth/login
?
App.js
class App extends Component {
constructor(props) {
super(props);
this.props.fetchProducts();
this.props.fetchUser();
}
render() {
return (
<Switch>
<Route exact path='/cart' render={() => this.props.isLoggedIn ?
<Checkout /> :
<Redirect to='http://localhost:8080/auth/login' />
} />
<Route exact path='/user/account/profile' render={() => <Profile />} />
<Route exact path='/' render={() => <MainPage />} />
</Switch>
);
}
}
Клиентский пакет.json
{
"name": "client",
"version": "0.1.0",
"private": true,
"dependencies": {
"@material-ui/core": "^3.6.2",
"prop-types": "^15.6.2",
"react": "^16.4.1",
"react-dom": "^16.4.1",
"react-redux": "^5.0.7",
"react-router-dom": "^4.3.1",
"react-scripts": "^2.1.3",
"redux": "^4.0.0",
"redux-logger": "^3.0.6",
"redux-thunk": "^2.3.0"
},
"proxy": "http://localhost:8080",
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
]
}