N8N iframe CORS

Hello, I am a beginner here! So, I’ll start by thanking you for the help!
I am trying to embed n8n in an iframe in a system I am developing.
n8n is on one server, and my system is on another server. n8n is running in a Docker environment.
My system is at the address https://a.teste.com.br, and n8n is at the address https://b.teste.com.br.
However, when accessing the screen of my system that contains the iframe with n8n, it gives a CORS error.
How can I modify the Traefik and n8n Docker configurations to make it work?
I’ll include the yaml files for each below.
Thanks in advance!
Traefik:

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Hi @wagner.dracha,

Welcome to the community :tada:

Tip for sharing your workflow in the forum

Pasting your n8n workflow


Ensure to copy your n8n workflow and paste it in the code block, that is in between the pairs of triple backticks, which also could be achieved by clicking </> (preformatted text) in the editor and pasting in your workflow.

```
<your workflow>
```

Make sure that you’ve removed any sensitive information from your workflow and include dummy data or pinned data as much as you can!


Could you maybe share your Traefik/docker configurations? Also another thing you can check is the CORS setting in your embedded chat.

Hey. When I try to post my configurations, I got 403 error:

Well, I post a image with the traefik configurations.
Traefik:

n8n:

version: "3.7"

services:
  n8n_editor:
    image: n8nio/n8n:latest
    command: start
    networks:
      - minha_rede
    environment:
      - DB_TYPE=postgresdb
      - DB_POSTGRESDB_DATABASE=n8n_queue
      - DB_POSTGRESDB_HOST=postgres
      - DB_POSTGRESDB_PORT=5432
      - DB_POSTGRESDB_USER=postgres
      - DB_POSTGRESDB_PASSWORD=....
      - N8N_ENCRYPTION_KEY=...
      - N8N_HOST=b.teste.com.br
      - N8N_EDITOR_BASE_URL=https://b.teste.com.br/
      - N8N_PROTOCOL=https
      - NODE_ENV=production
      - WEBHOOK_URL=https://webhookb.teste.com.br/
      - EXECUTIONS_MODE=queue
      - QUEUE_BULL_REDIS_HOST=redis
      - QUEUE_BULL_REDIS_PORT=6379
      - QUEUE_BULL_REDIS_DB=2
      - NODE_FUNCTION_ALLOW_EXTERNAL=moment,lodash,moment-with-locales
      - EXECUTIONS_DATA_PRUNE=true
      - EXECUTIONS_DATA_MAX_AGE=336
      - GENERIC_TIMEZONE=America/.....
      - TZ=America/....

    deploy:
      mode: replicated
      replicas: 1
      placement:
        constraints:
          - node.role == manager
      resources:
        limits:
          cpus: "0.5"
          memory: 1024M
      labels:
        - traefik.enable=true
        - traefik.http.routers.n8n_editor.rule=Host(`b.teste.com.br`)
        - traefik.http.routers.n8n_editor.entrypoints=websecure
        - traefik.http.routers.n8n_editor.priority=1
        - traefik.http.routers.n8n_editor.tls.certresolver=letsencryptresolver
        - traefik.http.routers.n8n_editor.service=n8n_editor
        - traefik.http.services.n8n_editor.loadbalancer.server.port=5678
        - traefik.http.services.n8n_editor.loadbalancer.passHostHeader=1

  n8n_webhook:
    image: n8nio/n8n:latest
    command: webhook
    networks:
      - minha_rede
    environment:
      - DB_TYPE=postgresdb
      - DB_POSTGRESDB_DATABASE=n8n_queue
      - DB_POSTGRESDB_HOST=postgres
      - DB_POSTGRESDB_PORT=5432
      - DB_POSTGRESDB_USER=postgres
      - DB_POSTGRESDB_PASSWORD=....
      - N8N_ENCRYPTION_KEY=...
      - N8N_HOST=b.teste.com.br
      - N8N_EDITOR_BASE_URL=https://b.teste.com.br/
      - N8N_PROTOCOL=https
      - NODE_ENV=production
      - WEBHOOK_URL=https://webhookb.teste.com.br/
      - EXECUTIONS_MODE=queue
      - QUEUE_BULL_REDIS_HOST=redis
      - QUEUE_BULL_REDIS_PORT=6379
      - QUEUE_BULL_REDIS_DB=2
      - NODE_FUNCTION_ALLOW_EXTERNAL=moment,lodash,moment-with-locales
      - EXECUTIONS_DATA_PRUNE=true
      - EXECUTIONS_DATA_MAX_AGE=336
      - GENERIC_TIMEZONE=America/....
      - TZ=America/....
    deploy:
      mode: replicated
      replicas: 2
      placement:
        constraints:
          - node.role == manager
      resources:
        limits:
          cpus: "0.5"
          memory: 1024M
      labels:
        - traefik.enable=true
        - traefik.http.routers.n8n_webhook.rule=(Host(`webhookb.teste.com.br`))
        - traefik.http.routers.n8n_webhook.entrypoints=websecure
        - traefik.http.routers.n8n_webhook.priority=1
        - traefik.http.routers.n8n_webhook.tls.certresolver=letsencryptresolver
        - traefik.http.routers.n8n_webhook.service=n8n_webhook
        - traefik.http.services.n8n_webhook.loadbalancer.server.port=5678
        - traefik.http.services.n8n_webhook.loadbalancer.passHostHeader=1


  n8n_worker:
    image: n8nio/n8n:latest
    command: worker --concurrency=10
    networks:
      - minha_rede
    environment:
      - DB_TYPE=postgresdb
      - DB_POSTGRESDB_DATABASE=n8n_queue
      - DB_POSTGRESDB_HOST=postgres
      - DB_POSTGRESDB_PORT=5432
      - DB_POSTGRESDB_USER=postgres
      - DB_POSTGRESDB_PASSWORD=....
      - N8N_ENCRYPTION_KEY=.....
      - N8N_HOST=b.teste.com.br
      - N8N_EDITOR_BASE_URL=https://b.teste.com.br/
      - N8N_PROTOCOL=https
      - NODE_ENV=production
      - WEBHOOK_URL=https://webhookb.teste.com.br/
      - EXECUTIONS_MODE=queue
      - QUEUE_BULL_REDIS_HOST=redis
      - QUEUE_BULL_REDIS_PORT=6379
      - QUEUE_BULL_REDIS_DB=2
      - NODE_FUNCTION_ALLOW_EXTERNAL=moment,lodash,moment-with-locales
      - EXECUTIONS_DATA_PRUNE=true
      - EXECUTIONS_DATA_MAX_AGE=336
      - GENERIC_TIMEZONE=America/....I
      - TZ=America/.....
    deploy:
      mode: replicated
      replicas: 1
      placement:
        constraints:
          - node.role == manager
      resources:
        limits:
          cpus: "0.5"
          memory: 1024M

networks:
  minha_rede:
    name: minha_rede
    external: true

I could post the n8n configuration, but I couldn’t post the traefik configurations. So I post a image.

So, anwering yours questions:
n8n version: 1.58.2
database: postgres (docker)
n8n EXECUTIONS_PROCESS setting: own
running n8n via docker
Operation system: I can’t share this information

I have a cloudflare dns service:
You <------> Cloudflare <--------> Server (my system) <------> Cloudflare <--------> Server (n8n and postgres sql)

Hi @aya, thanks!
So I post it, but the information was remove. So I tried to post again by photo. The n8n configurations I could post the code.

Someone can help me?

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