我有一个 Django 后端,其中粘贴了 React 项目的构建目录(运行后
npm run build
)。当通过代码打开时,我看到一堆 React 项目打开的网页,即 <Link className='dropdown-item' to='/customer/dashboard'>Dashboard</Link>
打开由 <Route path="/customer/dashboard" element={<Dashboard />} />
路由的组件(即仪表板组件启动)。但是,如果我将 URL 更新为 http://127.0.0.1:8000/customer/dashboard
,甚至使用上述 URL 刷新页面,则会收到 404 错误。
我还有另一个问题,某些页面甚至无法通过代码打开。所以我想知道为什么会这样。
以下是我在 urls.py(Django 项目)中的代码片段
path('api/token/refresh/', jwt_views.TokenRefreshView.as_view(), name='token_refresh'),
path('', views.index, name = 'index'),
views.py
from django.views.generic import TemplateView
from django.views.decorators.cache import never_cache
index = never_cache(TemplateView.as_view(template_name='index.html'))