我有一个使用react router的单页react应用程序,我正在尝试向我的路由器添加一条新路由,这似乎工作正常,在本地使用npm start运行我的应用程序,并且工作正常,当我运行该问题时尝试使用http-server-spa部署它,除了新路由以外,我所有的路由均有效,该新路由与其他路由之间的区别在于它是组合路由(新路由为/ code / azure):>
const routesConfig = [
{ path: '/login', component: Login, requireAuthentication: false },
{
path: '/user-information',
component: UserInformation,
requireAuthentication: true
},
{ path: '/usa', component: USA, requireAuthentication: true },
{ path: '/knowledge', component: Knowledge, requireAuthentication: true },
{ path: '/labour', component: Labour, requireAuthentication: true },
{ path: '/administration', component: Administration, requireAuthentication: true },
{ path: '/createUser', component: CreateUser, requireAuthentication: true },
{ path: '/UploadDocument', component: UploadDocument, requireAuthentication: true },
{ path: '/showDocument', component: ShowDocument, requireAuthentication: true },
{ path: '/editDocument', component: EditDocument, requireAuthentication: true },
{ path: '/home', component: Home, requireAuthentication: true, exact: true },
{ path: '/edit-user', component: EditUser, requireAuthentication: true },
{ path: '/upload-report', component: UploadReport, requireAuthentication: true },
{ path: '/code/azure', component: SSOSesionStarter, requireAuthentication: false },
{ path: '/', component: Home, requireAuthentication: true, exact: true},
{ component: Error404, requireAuthentication: false }
];
我在前端遇到的错误看起来像这样(由于正在开发Web应用程序,因此我将省略该域):
*https://frontend.****.***.***.com/code/static/css/2.0f87f62a.chunk.css net::ERR_ABORTED 404*
我认为由于它是一个单页应用程序,因此应该在.... com / static / css / blabla中查找该块,但它正在.... com / code / static中使用(因为代码是我的路径的第一部分)
我已经尝试将我的主页"homepage": "."
更改为"homepage": "/"