ResponseError: Invalid origin! after upgrade to 1.88 - Conneciton Lost

Hey there,

I get an “ResponseError: Invalid origin!” after upgrading to 1.88 it was working fine with the previous version (I think it was 1.86). In the UI I get the “Connection lost notificaiton”

I’m using self hosted version and docker compose to run it with traefik

ResponseError: Invalid origin!
    at Push.handleRequest (/usr/local/lib/node_modules/n8n/dist/push/index.js:85:19)
    at /usr/local/lib/node_modules/n8n/dist/push/index.js:67:94
    at Layer.handleRequest (/usr/local/lib/node_modules/n8n/node_modules/router/lib/layer.js:152:17)
    at trimPrefix (/usr/local/lib/node_modules/n8n/node_modules/router/index.js:342:13)
    at /usr/local/lib/node_modules/n8n/node_modules/router/index.js:297:9
    at processParams (/usr/local/lib/node_modules/n8n/node_modules/router/index.js:582:12)
    at next (/usr/local/lib/node_modules/n8n/node_modules/router/index.js:291:5)
    at AuthService.authMiddleware (/usr/local/lib/node_modules/n8n/dist/auth/auth.service.js:67:13)

this is my docker compose file

version: "3.7"

services:
  traefik:
    image: "traefik"
    restart: always
    command:
      - "--api=true"
      - "--api.insecure=true"
      - "--providers.docker=true"
      - "--providers.docker.exposedbydefault=false"
      - "--entrypoints.web.address=:80"
      - "--entrypoints.web.http.redirections.entryPoint.to=websecure"
      - "--entrypoints.web.http.redirections.entrypoint.scheme=https"
      - "--entrypoints.websecure.address=:443"
      - "--certificatesresolvers.mytlschallenge.acme.tlschallenge=true"
      - "--certificatesresolvers.mytlschallenge.acme.email=${SSL_EMAIL}"
      - "--certificatesresolvers.mytlschallenge.acme.storage=/letsencrypt/acme.json"
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - traefik_data:/letsencrypt
      - /var/run/docker.sock:/var/run/docker.sock:ro


n8n:
    image: docker.n8n.io/n8nio/n8n
    restart: always
    labels:
      - traefik.enable=true
      - traefik.http.routers.n8n.rule=Host(`${SUBDOMAIN}.${DOMAIN_NAME}`)
      - traefik.http.routers.n8n.tls=true
      - traefik.http.routers.n8n.entrypoints=web,websecure
      - traefik.http.routers.n8n.tls.certresolver=mytlschallenge
      - traefik.http.middlewares.n8n.headers.SSLRedirect=true
      - traefik.http.middlewares.n8n.headers.STSSeconds=315360000
      - traefik.http.middlewares.n8n.headers.browserXSSFilter=true
      - traefik.http.middlewares.n8n.headers.contentTypeNosniff=true
      - traefik.http.middlewares.n8n.headers.forceSTSHeader=true
      - traefik.http.middlewares.n8n.headers.SSLHost=${DOMAIN_NAME}
      - traefik.http.middlewares.n8n.headers.STSIncludeSubdomains=true
      - traefik.http.middlewares.n8n.headers.STSPreload=true
      - traefik.http.routers.n8n.middlewares=n8n@docker
      - traefik.http.routers.n8n.service=n8n
      - traefik.http.services.n8n.loadbalancer.server.port=5678
    ports:
      - "127.0.0.1:5679:5678"
    environment:
      - N8N_HOST=${SUBDOMAIN}.${DOMAIN_NAME}
      - N8N_PORT=5678
      - N8N_PROTOCOL=https
      - NODE_ENV=production
      - WEBHOOK_URL=${SUBDOMAIN}.${DOMAIN_NAME}
      - GENERIC_TIMEZONE=${GENERIC_TIMEZONE}
      - N8N_PUSH_BACKEND=sse
      - N8N_EDITOR_BASE_URL=${SUBDOMAIN}.${DOMAIN_NAME}
      - VUE_APP_URL_BASE_API=${SUBDOMAIN}.${DOMAIN_NAME}
    volumes:
      - n8n_data:/home/node/.n8n
      - local_files:/files

I’ve tried different solutions but none of them works (like setting VUE_APP_URL_BASE_API, N8N_PUSH_BACKEND, etc)

Any help is appreciated. Thanks

1 Like

Up for this, got same problem… already tried to create custom rule for Origin to hostname on cloudflare but not fix anything

I figured out the issue, in my case the docker was running with a proxy from apache so I had to add this to the apache config:

ProxyPreserveHost On
RequestHeader set Origin “https://n8n… domain”
RequestHeader set X-Forwarded-Proto https

2 Likes

hey thanks for your insight, its fixed my n8n on swarm cluster. just config nginx by adding this:
proxy_set_header Host $host;
proxy_set_header Origin $http_origin;

For my other Openlitespeed webserver solved from this solution by config on cloudflare

1 Like

This solved the problem for me using nginx as reverse proxy

location / {
        proxy_pass http://localhost:5678/;
        proxy_http_version 1.1;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Host $host;
        proxy_set_header Origin $http_origin;
    }
2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.