我为应用程序提供了以下route.js文件,该文件将部署在IIS门户文件夹下名为KM的子文件夹中。我提交凭据并登录后,它会导航到错误的URL。
// routes.js
const APP_BASE_URL = '/portal/KM/';
export const APP_URLS = {
HOME: `${APP_BASE_URL}`,
LOGIN: `${APP_BASE_URL}login`,
EXPLORER: `${APP_BASE_URL}explorer`,
};
export default ({ childProps }) =>
<Switch>
<AppliedRoute path="/" exact component={Home} props={childProps} />
<UnauthenticatedRoute path="/login" exact component={Login} props={childProps} />
<AuthenticatedRoute path="/explorer" exact component={FileExplorer} props={childProps} />
<AuthenticatedRoute path="/explorer/:id" exact component={FileExplorer} props={childProps} />
{ /* <AuthenticatedRoute path="/notes/new" exact component={NewNote} props={childProps} />
Finally, catch all unmatched routes */}
<Route component={NotFound} />
</Switch>;
以及以下login.js文件:
// login.js
//...
import { APP_URLS } from "../Routes";
//...
//...
const handleSubmit = (event) => {
event.preventDefault();
postAuthenticateUser({
username: username,
password: password
})
.then(res => {
if (res.status === 200) {
localStorage.setItem("token", responseToken);
if (responseToken != null && responseToken !== "") {
props.setToken(responseToken);
}
props.history.push(APP_URLS.EXPLORER);
}
})
.catch(err => {
setErrorMessage(err.response.data);
});
}
为什么浏览器导航到/portal/KM/portal/explorer
而不是/portal/KM/explorer
?