Unable to Make API Call through Flutter (Web)

Hi,

I’m making a Flutter Web App with which we can enable or disable the workflows in n8n.
Im making a GET Request to http://my_domain/rest/workflows to get the workflows. I also passed the basicAuth value in the header.

But while making the Request I get the XMLHttpRequest error.

It works well on android app (mobile version of flutter), but on web version of flutter it just gives me this error. I searched about this and got that its related to CORS.

Also I got a potential solution, but dont know how we can add into n8n.

Added .htaccess file in web folder

<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>

Thanks

There is currently no way to do that directly in n8n as the API is currently only meant to be used by the editor-UI and not by anything else. So if you want set that header, you would have to set it on a reverse-proxy in front of n8n. If you are using traefik or nginx, it should be possible to manually set any kind of header you want.

1 Like

Thanks @jan
Will try with the reverse-proxy and check with that

1 Like