Hello, I’m creating a Angular application and I need to make API calls with webhooks on n8n. When I make a call to a webhook, I have an error like “Reason: CORS header ‘Access-Control-Allow-Origin’ does not match ‘localhost:8800’”
What I did until now ?
When I had this error the first time, I added the response header "Access-Control-Allow-Origin : * " to the webhook, and it worked but only for a webhook with the GET HTTP Method. But when I tried with a POST HTTP Method, I have the error again… So I don’t know what I can do…
(I hope I am understandable ^^ ask if you have any question )
What is the error message (if any)? (On the web browser)
Hey @Quentinus, I am not familiar with httpClient, but I suspect it would cause your browser to send the OPTIONS preflight request described here which seems to be what fails here. You could verify this in the network console of your browser.
n8n would not handle these preflight requests, so you would need to configure a reverse proxy sitting in front of n8n accordingly. You could alternatively check if your web app can make a request with a text/plain content type instead as these would not be subject to CORS iirc.
Actually, looking at today’s changelog it seems like an upgrade to 0.183.0 might fix the problem too. It includes an update to handle OPTIONS requests from any source:
So definitely worth trying out if you haven’t implemented anything else yet.
It works now ^^ I waited a few hours and I had the update, I don’t know why I needed to wait for the update but it’s ok Thank you again for your help !
Hey @igcorreia, this is a rather old thread and I don’t have all details present anymore. Iirc you’d need to add the Access-Control-Allow-Headers header on the reverse proxy level (so outside of n8n) for this to work.
Depending on the application you are using you could also consider using a different content type to avoid CORS as suggested here.