上一篇:以下职位没有解决方案对我起作用: Blank page after running build on create-react-app
在我的例子中,App.js的主要函数:
function App() {
return (
<div className='App'>
<Routes>
<Route index path='/' element={<Login />} />
<Route
path='/home'
element={<ProtectedRoute children={Home} />}
/>
</Routes>
</div>
)
}
和index.js:
root.render(
<div className="flex justify-center bg-black overscroll-contain">
<div className="w-full max-w-[70rem]">
<Auth0Provider
domain={domain}
clientId={clientId}
authorizationParams={{
redirect_uri: window.location.origin,
}}>
<BrowserRouter>
<App />
</BrowserRouter>
</Auth0Provider>
</div>
</div>
);
建筑物被放置在一个办公室.我使用类似的URL访问它:https://test.myweb.com/MyApp.
我在Package.json:"homepage": "."
和"homepage": "https://test.myweb.com/MyApp"
上都try 了建议的配置,但都不适合我.同时,我一直在try 如下所示的.htAccess,但没有成功:
RewriteEngine on
#for app in subdirectory
RewriteBase /test/testingProjects/MyApp
Header set Cache-Control "no-cache"
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^.*/test/testingProjects/MyApp.* /test/testingProjects/MyApp/index.html [L]
#for root app
RewriteBase /
Header set Cache-Control "no-cache"
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule . /index.html [L]
# DISABLE CACHING
<IfModule mod_headers.c>
Header set Cache-Control "no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires 0
</IfModule>
<FilesMatch "\.(html|js)$">
<IfModule mod_expires.c>
ExpiresActive Off
</IfModule>
<IfModule mod_headers.c>
FileETag None
Header unset ETag
Header unset Pragma
Header unset Cache-Control
Header unset Last-Modified
Header set Pragma "no-cache"
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Expires "Thu, 1 Jan 1970 00:00:00 GMT"
</IfModule>
</FilesMatch>
在这一点上,我有不同的设置来判断我不确定如何或什么设置:
-
BrowserRouter
个正确的用法 - 关于package.json的Property
'homepage'
-
.htaccess
个文件..htaccess
个文件.
值得一提的是,登录是使用Auth0构建的,以防这种情况下需要特殊配置.
开发人员控制台显示文件是某种类型的读取,但它在根级别停止,不会进一步:
<body>
<noscript>This app requires Javascript to function.</noscript>
<div id="root"></div>
</body