I am currently working on a Django 2 + Angular 6 project. As part of my build process, I move the compiled JS files into Django's static folder.
However, I encounter an issue whenever I try to access a link, such as , the browser automatically redirects me to .. It seems something is not set up correctly.
My application uses the hash location strategy. While the page functions properly, if I refresh at the redirected URL or visit it directly, I receive a 404 error.
In my urls.py
file, the routes are defined as follows:
urlpatterns = [
path('', IndexView.as_view()),
path('admin/', admin.site.urls),
path('api/v1/', include(router.urls)),
]
The first URL pattern points to an IndexView
, which is essentially a TemplateView
rendering this index.html
:
{% load static from staticfiles %}
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8>
<link rel="icon" type="image/x-icon" href="{% static 'favicon.ico' %}">
</head>
<body>
<app-root></app-root>
<script type="text/javascript" src="{% static 'uploader/runtime.js' %}"></script>
<script type="text/javascript" src="{% static 'uploader/polyfills.js' %}"></script>
<script type="text/javascript" src="{% static 'uploader/styles.js' %}"></script>
<script type="text/javascript" src="{% static 'uploader/vendor.js' %}"></script>
<script type="text/javascript" src="{% static 'uploader/main.js' %}"></script>
</body>
</html>