I’m running a self-hosted instance of n8n using Docker and exposing it via ngrok. When trying to access the n8n REST API from my Next.js frontend, I’m encountering a CORS error: “No ‘Access-Control-Allow-Origin’ header is present on the requested resource.” I couldn’t find an environment variable in the docs to enable or configure CORS for the n8n API. Is there a recommended way to allow cross-origin requests when running n8n in Docker with ngrok? Any guidance or workaround would be appreciated!
instance information
Debug info
core
n8nVersion: 1.92.2
platform: docker (self-hosted)
nodeJsVersion: 20.19.0
database: sqlite
executionMode: regular
concurrency: -1
license: enterprise (production)
consumerId: 9c4127e9-94d0-457f-a716-3848f0ac12fe
storage
success: all
error: all
progress: false
manual: true
binaryMode: filesystem
pruning
enabled: true
maxAge: 336 hours
maxCount: 10000 executions
client
userAgent: mozilla/5.0 (windows nt 10.0; win64; x64) applewebkit/537.36 (khtml, like gecko) chrome/136.0.0.0 safari/537.36
Nice, thanks for providing debug details, not many people know about it
The CORS (Cross-Origin Resource Sharing) issue you are facing is due to the fact that the Access-Control-Allow-Origin header is either missing or incorrectly configured in your webhook response.
In your n8n .env file or when running n8n, make sure you set:
@King_Samuel_David In docker, I’ve added the below envs while run a n8n container. but still same cors error occured while call the n8n create workflow api from my own frontend next js code.