i am using a simple ai agent chat installed on my wordpress site. mywordpress site and n8n installation are both on hostinger but on two different servers. my n8n instance is self hosted with docker compose on a vps with nginx. this is my first time with n8n, or json or evening hosting a vps so i needless to say i am n00b
server {
listen 80;
listen [::]:80;
server_name n8n.xtreamsolution.net;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name n8n.xtreamsolution.net;
ssl_certificate /etc/letsencrypt/live/n8n.xtreamsolution.net/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/n8n.xtreamsolution.net/privkey.pem;
location / {
proxy_pass http://127.0.0.1:5678;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_cache_bypass $http_upgrade;
chunked_transfer_encoding off;
}
location /webhook {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' 'https://xtreamsolution.net';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'Content-Type';
add_header 'Access-Control-Max-Age' 86400;
return 204;
}
# Remove the duplicate header here, let the if block handle it
proxy_pass http://127.0.0.1:5678;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Upgrade $http_upgrade;
I’m experiencing an issue where my webhook endpoint successfully receives a request and returns a 200 OK status, but the response body is empty, resulting in my frontend displaying:
“Empty response from server.”
Workflow Setup:
- I’m using a Chat Trigger node that passes user input to an AI Agent node.
- The AI Agent is configured with a System Message that forces JSON output (e.g.,
{ "response": "Hello" }). - I have a Respond to Webhook node at the end of the workflow.
- Respond to Webhook → Respond With: JSON
- Response Body:
json
CopyEdit
{{ { "output": $json.response || "No AI response" } }}
What I Have Tried:
- Verified that the webhook URL is being called correctly from the browser console:
bash
CopyEdit
POST https://n8n.xtreamsolution.net/webhook/f406671e-c954-4691-b39a-66c90aa2f103/chat
Status: 200 OK
- Tested with a Function node returning a static JSON:
js
CopyEdit
return [{ json: { response: "Test response from n8n" } }];
Even then, my frontend logs Bot: Empty response from server.
3. Checked CORS settings — Access-Control-Allow-Origin is set to my domain (https://xtreamsolution.net).
4. Verified the AI Agent node outputs data, but the final Respond to Webhook node always returns empty.
5. Tried removing the Output Parser and directly feeding JSON to the Respond to Webhook node — same issue.
Additional Notes:
- Frontend fetch request:
js
CopyEdit
const response = await fetch('https://n8n.xtreamsolution.net/webhook/f406671e-c954-4691-b39a-66c90aa2f103/chat', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ message })
});
const data = await response.json();
console.log(data);
- The console logs:
sql
CopyEdit
Bot: Empty response from server.