N8n on a subpath - issues with traefik and caddy

Describe the problem/error/question

n8n not working behind traefik and caddy. When we deploy a standalone docker compose stack behind a traefik firewall routing to caddy and then to a n8n subpath we get an incorrect path from n8n for assets .

Running in a github codespace the same caddy config works perfectly well

Comparing the two systems, in codespace n8n requests assets with the sub path. In deployment the sub path ismissing. I have compared both docker compose files and the n8n entry is identical - image, variables (except content) etc

What is the error message (if any)?

Failed to load module script: Expected a JavaScript-or-Wasm module script but the server responded with a MIME type of “text/html”. Strict MIME type checking is enforced for module scripts per HTML spec.

Information on your n8n setup

  • n8n version: 114-3:
  • Database (default: SQLite): postgres
  • n8n EXECUTIONS_PROCESS setting (default: own, main): queue
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: Ubuntu 24.10

hello @jmls

What is your n8n config? How the variable N8N_PATH is set?

Hey @barn4k thanks for responding

I have these three vars

N8N_PATH=/service/automation/
N8N_EDITOR_BASE_URL=https://${STACK}.${DOMAIN}/service/automation/ VUE_APP_URL_BASE_API=https://${STACK}.${DOMAIN:}/service/automation/

STACK.DOMAIN is foo.co.uk

I’ve been tearing my hair out trying to understand why the identical config works in codespaces

Any clues would be gratefully received !