The origin-zone map drew its background from a public tile server, which made it
the only part of the admin page that depended on a third-party domain — and the
part that breaks. Where a viewer's network, proxy or browser filter refuses
tile.openstreetmap.org (the refusal arrives as a 403) the map never draws, while
the page, the Leaflet bundle and the polygon data are all same-origin and fine.
Fetch the tiles server-side and serve them from /tiles/{z}/{x}/{y}.png: cached
on disk, so a page opened repeatedly does not re-fetch, and gated on being
signed in, so the route is not an open tile relay. The upstream stays
configurable via LEAFLET_TILE_URL, and LEAFLET_TILE_PROXY_ENABLED=False puts the
browser back on direct fetches.
When a tile still cannot be fetched, answer an empty tile rather than an error
page and say so under the map, instead of leaving a viewer with a blank grid and
no explanation.
34 lines
1.4 KiB
Python
34 lines
1.4 KiB
Python
from django.contrib import admin
|
|
from django.http import HttpResponseRedirect
|
|
from django.urls import path, include
|
|
from django.conf import settings
|
|
from django.conf.urls.static import static
|
|
from rest_framework.authtoken import views as drf_auth
|
|
|
|
from apps.core.tiles import tile_view
|
|
|
|
urlpatterns = [
|
|
path("", lambda r: HttpResponseRedirect("/admin/")),
|
|
path("tiles/<int:z>/<int:x>/<int:y>.png", tile_view, name="tile"),
|
|
path("grappelli/", include("grappelli.urls")),
|
|
path("admin/", admin.site.urls),
|
|
path("oidc/", include("mozilla_django_oidc.urls")),
|
|
path("api/auth/", drf_auth.obtain_auth_token),
|
|
path("api/", include("apps.users.urls")),
|
|
path("api/", include("apps.subscriptions.urls")),
|
|
path("api/", include("apps.batches.urls")),
|
|
path("api/", include("apps.qc.urls")),
|
|
path("api/", include("apps.shipments.urls")),
|
|
path("api/", include("apps.documents.urls")),
|
|
path("api/", include("apps.capa.urls")),
|
|
path("api/", include("apps.esg.urls")),
|
|
path("api/", include("apps.compliance.urls")),
|
|
path("api/", include("apps.ai.urls")),
|
|
path("api/", include("apps.notifications.urls")),
|
|
path("ops/", include("apps.ops.urls")),
|
|
path("portal/", include("apps.buyer.urls")),
|
|
]
|
|
|
|
if settings.DEBUG:
|
|
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
|
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
|