2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-28 03:26:45 +00:00

Fix asset file serving (#9295)

- Backport of https://github.com/inventree/InvenTree/pull/9292
This commit is contained in:
Oliver 2025-03-14 09:04:42 +11:00 committed by GitHub
parent 21d266ab95
commit 3cae0d5066
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 1 additions and 19 deletions

View File

@ -87,11 +87,6 @@ class TemplateTagTest(InvenTreeTestCase):
self.assertNotIn('show_server_selector', rsp)
self.assertEqual(rsp['server_list'], ['aa', 'bb'])
def test_redirects(self):
"""Test the redirect helper."""
response = self.client.get('/assets/testpath')
self.assertEqual(response.url, '/static/web/assets/testpath')
class TestWebHelpers(InvenTreeAPITestCase):
"""Tests for the web helpers."""

View File

@ -2,7 +2,6 @@
from django.conf import settings
from django.http import JsonResponse
from django.shortcuts import redirect
from django.urls import include, path, re_path
from django.views.decorators.csrf import ensure_csrf_cookie
from django.views.generic import TemplateView
@ -12,16 +11,6 @@ from rest_framework import permissions, serializers
from InvenTree.mixins import RetrieveUpdateAPI
class RedirectAssetView(TemplateView):
"""View to redirect to static asset."""
def get(self, request, *args, **kwargs):
"""Redirect to static asset."""
return redirect(
f'{settings.STATIC_URL}web/assets/{kwargs["path"]}', permanent=True
)
class PreferredSerializer(serializers.Serializer):
"""Serializer for the preferred serializer session setting."""
@ -72,14 +61,12 @@ class PreferredUiView(RetrieveUpdateAPI):
spa_view = ensure_csrf_cookie(TemplateView.as_view(template_name='web/index.html'))
assets_path = path('assets/<path:path>', RedirectAssetView.as_view())
urlpatterns = [
path(
f'{settings.FRONTEND_URL_BASE}/',
include([
assets_path,
path(
'set-password?uid=<uid>&token=<token>',
spa_view,
@ -88,7 +75,6 @@ urlpatterns = [
re_path('.*', spa_view),
]),
),
assets_path,
path(settings.FRONTEND_URL_BASE, spa_view, name='platform'),
]

View File

@ -48,6 +48,7 @@ export default defineConfig({
uploadToken: process.env.CODECOV_TOKEN
})
],
base: '',
build: {
manifest: true,
outDir: '../../src/backend/InvenTree/web/static/web',