CORS in Cloud Hosted N8N

I’m working on replacing an old workflow automation tool with N8N and as part of that we will need to make calls triggering workflows from a different domain. In the version that’s available in npm, I didn’t have to do anything to get this to work. The cloud version, however seems to fail with a CORS error.

I noticed that there is a cors middleware in git but wasn’t sure how to use this in the cloud.

Information on your n8n setup

  • n8n version: 0.221.2
  • Running n8n via (Docker, npm, n8n cloud, desktop app): n8n cloud

Apparently the CORS middleware only runs when “inDevelopment” is true. Is there a way to have this turned on in an individual cloud instance?

Hi @RobAtForm, welcome to the community :tada:

I am afraid n8n cloud does not have an option to change the CORS behaviour on an per-instance basis, meaning the webhook node might not work with requests initiated by browsers.

So based on your use case you want to host n8n yourself. This would allow you to (for example) use a reverse proxy server capable of adding all required headers for CORS requests to succeed.

Hi @MutedJam! Thanks for the welcome and the response. One of my goals was to avoid having to self host. Our current provider comes in the form of a self hosted vm and it’s been a pain to maintain. I did come up with a workaround similar to GitHub - jpillora/xdomain: A pure JavaScript CORS alternative which effectively uses a workflow to return an HTML page with a small javascript that can be used as an iframe src.

There’s some code that needs to be executed on the sending side that more or less equates to a promise and a MessageChannel object. This is less than ideal, mostly because loading the iframe counts as an execution. Is there a way to host a file on my n8n cloud domain instead of relying on a workflow?

Thanks,
Rob

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