-
Notifications
You must be signed in to change notification settings - Fork 12.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Strange behavior of self-hosted version #595
Comments
Thanks a lot @amorev for reporting this issues. I can open n8n interface only in Google Chrome anonymous mode I cannot make REST request to my workflow because of CORS curl http://s3.obvu.ru:5678/webhook/5/webhook/test It would also work if you are on the same domain. So if you visit If you want to call it in the browser from a different domain (and or port) you should be able to do that by adding a response header like Hope that helps! |
Server of n8n always returns access-control-allow-origin: http://localhost:8080 inspite of what I wrote in webhook configuration |
Very strange. I just tested it and it works totally fine for me. So if I use this node: {
"nodes": [
{
"parameters": {
"path": "webhook",
"responseMode": "lastNode",
"options": {
"responseHeaders": {
"entries": [
{
"name": "Access-Control-Allow-Origin",
"value": "http://example.com:1234"
}
]
}
}
},
"name": "Webhook",
"type": "n8n-nodes-base.webhook",
"typeVersion": 1,
"position": [
507,
295
]
}
],
"connections": {}
} |
Ah sorry totally overlooked that you make an OPTIONS request. Yes, this one is currently not supported by n8n. That is why you also get the "404 Not Found". If you define a Webhook for POST it will only listen to POST requests and not for anything else like GET, OPTIONS, ... Honestly not sure right now what a good fix for this could be... Probably have to think about that a little bit. |
Thanks for your reply! |
I think I now how to fix it. I'll try to upgrade Webhook module locally and make PR if I success) |
Great, thanks a lot! The problem is, however, less of a technical one more of a design one and to think about if it makes sense in the long term and future use cases. Looking forward to your solution! |
Hi @amorev , Could you try setting your NODE_ENV environment variable to production? The "localhost:8080" value is hardcoded to the Access-Control-Allow-Origin header when n8n is not in production in order to deal with a CORS issue between the backend and frontend. |
Hi guys,
thanks! |
A combination of nginx config and NODE_ENV setting (both as mentioned above) worked for me on a self-hosted server! |
Closing this issue for now as a solution was posted. Feel free to reopen or make a new issue if you encounter any other problems. |
Hey, I'm using railway.app to self host n8n. Is there no way to fix this without a nginx config change? Since I cant do that in railway.app |
This no longer works because n8n already sends n8n/packages/cli/src/AbstractServer.ts Line 271 in 40a934b
You need to remove that line from the config and add extra headers to
At the same time, n8n provides full CORS support using middleware. Cors middleware is loaded only when your webhook runs in the development mode: n8n/packages/cli/src/AbstractServer.ts Line 154 in 40a934b
@netroy It looks like thorough refactoring and implementing custom CORS options in the WebHook trigger are still needed. |
Describe the bug
To Reproduce
Steps to reproduce the behavior:
I used docker for initialize application
fetch('http://s3.obvu.ru:5678/webhook/5/webhook/test')
) causing me errorExpected behavior
I expected that I'll be able to use it in simple google chrome tab and use it as rest api for simple frontend
Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: