我正在将旧的Laravel后台前端迁移到新的React应用程序。我在理解Nginx配置时遇到了一些问题。后台将并行运行,这就是我被告知新的react应用将如下所示的方式。
通常,URL可能看起来像这样
{base_url}/users
新的react应用将获得一个这样的URL
{base_url}?path=users
当{base_url}
指向Laravel项目中的另一条路线时,是否可能有这样的URL,它如何与react-router v4一起使用?
我的路由器
<Switch>
<Route
path=":userPath"
render={({ match: { path, ...props }, location }) => {
const pathname = location.pathname;
if (pathname.startsWith("?path")) {
console.log(path);
return (
<div>
<Route path={path} component={users} exact />
<Route
path={`${path}/:userId`}
render={({ match, history, location }) => {
return (
<UserPage
match={match}
location={location}
history={history}
userId={match.params.userId}
/>
);
}}
/>
<Route path={`${path}/create`} component={CreateUserForm} />
</div>
);
}
return null;
}}
/>
<Route component={PageNotFound} />
</Switch>;