n8n Webhook CORS Issues - Works in Postman, Fails from External Website

Anonymous
FREE

4 months ago

Problem: I have an n8n workflow deployed on Railway that works perfectly when tested with Postman, but fails with "Failed to fetch" CORS errors when called from my GitHub Pages website (https://tmg-ai.github.io).

What I've Tried:

  • Added all recommended CORS environment variables:

    • WEBHOOK_CORS_ALLOWED_ORIGINS=*

    • WEBHOOK_CORS_ALLOWED_METHODS=GET,HEAD,POST,PUT,DELETE,OPTIONS

    • WEBHOOK_CORS_ALLOWED_HEADERS=Content-Type,Authorization,X-Requested-With,Accept

    • N8N_EXPRESS_TRUST_PROXY=true

  • Added CORS headers to n8n response node

  • Confirmed webhook authentication is set to "None"

  • Multiple redeployments

Current Status:

  • Webhook works: Postman → Railway n8n

  • Webhook fails: GitHub Pages → Railway n8n (CORS error)

  • Production webhook URL shows 0.0.0.0:80 instead of proper Railway domain

Question: Is there a Railway-specific configuration I'm missing to allow cross-origin requests from external domains? Or is this a known limitation with Railway's networking setup?

Environment: n8n on Railway, single service (not using webhook processor template)

I'm desperate to figure this out since i need full deployment by Monday for a work deadline. This is my first multi-agent workflow deployment.

$10 Bounty

3 Replies

quadstrikesecurity
FREE

4 months ago

Try this solution

Set Railway Environment Variables :

# Railway-specific CORS

WEBHOOK_CORS_ALLOWED_ORIGINS=https://tmg-ai.github.io,https://*.github.io

N8N_HOST=0.0.0.0

N8N_PORT=80

N8N_PROTOCOL=https

N8N_WEBHOOK_URL=https://your-app.railway.app

# Force proper URL resolution

RAILWAY_STATIC_URL=https://your-app.railway.app

or else use Reverse Proxy :

// Use Railway as proxy

const proxyUrl = 'https://your-app.railway.app/webhook/proxy';

fetch(proxyUrl, {

method: 'POST',

headers: { 'Content-Type': 'application/json' },

body: JSON.stringify({

target: 'internal_webhook',

data: yourData

})

});


sim
FREE

4 months ago

Is there a Railway-specific configuration I'm missing to allow cross-origin requests from external domains? Or is this a known limitation with Railway's networking setup?

I do not see anything in their documentation about this


Anonymous
FREE

4 months ago

Thank you for the feedback. I had to move my workflow over to Render because I could not get Railway to work. Even though my workflow was perfect running locally on n8n, I had to change a lot of ndoes to get it run. Do most people just build workflows in Railway so there is no need to waste time doing this at deployment?