我正在尝试使用具有反应路由器的基准名称为on the react-router docs。这是由于base href被弃用。基本名称无法正常工作
这是我现在有:
import { Route, Router, useRouterHistory } from 'react-router';
import { createHistory } from 'history';
import { render } from 'react-dom';
var history = useRouterHistory(createHistory)({
basename: '/subdirectory'
});
render(
<Router history={history}>
<Route path='/' component={App}>
<Route path='next' component={Next} />
</Route>
</Router>,
document.getElementById('root')
);
当我去http://the-url.com/subdirectory
页面加载预期(渲染App
组件)。但是,当去http://the-url.com/subdirectory/next
时,我收到了404错误。我的nginx的配置是:
location /subdirectory {
alias /path/to/index.html;
index index.html;
try_files $uri $uri/ /path/to/index.html;
}
您是否找到任何解决方案? – Jatin
有没有人找到解决方案? –
任何解决方案呢? – stefanil