I have the barebones example SvelteKit app & a Traefik reverse proxy both running inside Docker containers.
When accessing the SK app directly (i.e. without going through Traefik first), the page content loads just fine:
However, when accessing it via Traefik, at the /sv-test path (as I intend to do under normal circumstances), the basic HTML scaffolding loads the same, but the actual text content is a generic 404 Not Found message:
The issue with loading the page content appears to have to do with the expected MIME type being incorrect for some reason, as the browser console showed these messages:
Loading module from “*http://192.168.1.149/node_modules/.pnpm/@sveltejs+kit@2.21.5_@sveltejs+vite-plugin-svelte@5.1.0_svelte@5.34.7_vite@6.3.5__svelte@5.34.7_vite@6.3.5/node_modules/@sveltejs/kit/src/runtime/client/entry.js*” was blocked because of a disallowed MIME type (“text/plain”).
Loading module from “*http://192.168.1.149/@fs/srv/.svelte-kit/generated/client/app.js*” was blocked because of a disallowed MIME type (“text/plain”).
...
Uncaught (in promise) TypeError: error loading dynamically imported module: http://192.168.1.149/node_modules/.pnpm/@sveltejs+kit@2.21.5_@sveltejs+vite-plugin-svelte@5.1.0_svelte@5.34.7_vite@6.3.5__svelte@5.34.7_vite@6.3.5/node_modules/@sveltejs/kit/src/runtime/client/entry.js
But why would the issue only arise when accessing the page via Traefik?
Here's my current Docker Compose & Traefik configuration:
compose.yaml:
services:
traefik:
container_name: traefik
image: traefik:latest
restart: unless-stopped
security_opt: [ no-new-privileges=true ]
networks: [ frontend ]
ports:
- 80:80
- 8080:8080
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./traefik.yaml:/traefik.yaml:ro
...
sv-test:
container_name: sv-test
build: { target: sv-test }
restart: unless-stopped
security_opt: [ no-new-privileges=true ]
networks: [ frontend ]
ports: [ 5173:5173 ]
labels:
- traefik.enable=true
- traefik.http.routers.sv-test.rule=Path(/sv-test)
#- traefik.http.services.sv-test.loadbalancer.server.port=5173
networks:
frontend:
name: frontend
#enable_ipv4: false
enable_ipv6: true
ipam: { config: [ { subnet: 2001:db8:2::/64 } ] }
traefik.yaml:
api:
dashboard: true
insecure: true
debug: false
entryPoints:
web:
address: :80
asDefault: true
# websecure:
# address: :443
providers:
docker:
endpoint: unix:///var/run/docker.sock
exposedByDefault: false
network: frontend

