fix: update proxy path logic in health-server and configure N8N_PATH in start.sh to support app base path routing
Browse files- health-server.js +3 -3
- start.sh +1 -0
health-server.js
CHANGED
|
@@ -231,8 +231,8 @@ const server = http.createServer(async (req, res) => {
|
|
| 231 |
}));
|
| 232 |
}
|
| 233 |
|
| 234 |
-
// Proxy to n8n
|
| 235 |
-
const proxyPath = pathname
|
| 236 |
const proxyHeaders = { ...req.headers, host: `127.0.0.1:${TARGET_PORT}`, "x-forwarded-for": req.socket.remoteAddress, "x-forwarded-proto": "https" };
|
| 237 |
|
| 238 |
const proxyReq = http.request({ hostname: TARGET_HOST, port: TARGET_PORT, path: proxyPath + url.search, method: req.method, headers: proxyHeaders }, (proxyRes) => {
|
|
@@ -250,7 +250,7 @@ const server = http.createServer(async (req, res) => {
|
|
| 250 |
|
| 251 |
server.on("upgrade", (req, socket, head) => {
|
| 252 |
const url = parseRequestUrl(req.url);
|
| 253 |
-
const proxyPath = url.pathname
|
| 254 |
const proxySocket = net.connect(TARGET_PORT, TARGET_HOST, () => {
|
| 255 |
proxySocket.write(`${req.method} ${proxyPath}${url.search} HTTP/${req.httpVersion}\r\n`);
|
| 256 |
for (let i = 0; i < req.rawHeaders.length; i += 2) {
|
|
|
|
| 231 |
}));
|
| 232 |
}
|
| 233 |
|
| 234 |
+
// Proxy to n8n (pass full path as n8n is configured with N8N_PATH=/app/)
|
| 235 |
+
const proxyPath = pathname;
|
| 236 |
const proxyHeaders = { ...req.headers, host: `127.0.0.1:${TARGET_PORT}`, "x-forwarded-for": req.socket.remoteAddress, "x-forwarded-proto": "https" };
|
| 237 |
|
| 238 |
const proxyReq = http.request({ hostname: TARGET_HOST, port: TARGET_PORT, path: proxyPath + url.search, method: req.method, headers: proxyHeaders }, (proxyRes) => {
|
|
|
|
| 250 |
|
| 251 |
server.on("upgrade", (req, socket, head) => {
|
| 252 |
const url = parseRequestUrl(req.url);
|
| 253 |
+
const proxyPath = url.pathname;
|
| 254 |
const proxySocket = net.connect(TARGET_PORT, TARGET_HOST, () => {
|
| 255 |
proxySocket.write(`${req.method} ${proxyPath}${url.search} HTTP/${req.httpVersion}\r\n`);
|
| 256 |
for (let i = 0; i < req.rawHeaders.length; i += 2) {
|
start.sh
CHANGED
|
@@ -16,6 +16,7 @@ SPACE_HOST_DETECTED="${SPACE_HOST_OVERRIDE:-${SPACE_HOST:-}}"
|
|
| 16 |
if [ -n "$SPACE_HOST_DETECTED" ]; then
|
| 17 |
export N8N_HOST="${N8N_HOST:-$SPACE_HOST_DETECTED}"
|
| 18 |
# Updated for /app base path
|
|
|
|
| 19 |
export WEBHOOK_URL="${WEBHOOK_URL:-https://${SPACE_HOST_DETECTED}/app/}"
|
| 20 |
export N8N_EDITOR_BASE_URL="${N8N_EDITOR_BASE_URL:-https://${SPACE_HOST_DETECTED}/app/}"
|
| 21 |
fi
|
|
|
|
| 16 |
if [ -n "$SPACE_HOST_DETECTED" ]; then
|
| 17 |
export N8N_HOST="${N8N_HOST:-$SPACE_HOST_DETECTED}"
|
| 18 |
# Updated for /app base path
|
| 19 |
+
export N8N_PATH="/app/"
|
| 20 |
export WEBHOOK_URL="${WEBHOOK_URL:-https://${SPACE_HOST_DETECTED}/app/}"
|
| 21 |
export N8N_EDITOR_BASE_URL="${N8N_EDITOR_BASE_URL:-https://${SPACE_HOST_DETECTED}/app/}"
|
| 22 |
fi
|