使用 React 在服务器端渲染中路由

时间:2021-03-04 02:42:07

标签: reactjs react-router server-side-rendering

我在 React 服务器端渲染应用程序中遇到了一个令人困惑的路由问题。

export default [
  {
    ...App,
    routes: [
      { path: '/', ...Home, exact: true },
      { path: '/test/test', ...Test },
      { path: '/auth/signUp', ...SignUp, exact: true },
      { path: '/auth/signIn', ...SignIn },
      { path: '/auth/signOut', ...SignOut },
      { ...NotFound }, // this is how we use not-found page -- by not providing path
    ],
  },
];

当我转到像 /signUp 或 /test 这样的路线时,一切正常。但是当我去 /auth/signUp 时。页面呈现,但它在控制台中显示错误,类似于无法转到“/auth/bundle.js”

Error is: 
GET https://ticketing.dev/test/bundle.js net::ERR_ABORTED 404

很明显有一些技巧可以完成这项工作。请告诉我

0 个答案:

没有答案