Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/plugins/default/error-response-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,17 @@ export const errorResponsePlugin: Plugin = definePlugin((proxyServer, options) =
if (!req || !res) {
throw err; // "Error: Must provide a proper URL as target"
}
// Log full details server-side where only admins can see them
console.error(`Proxy error for ${req.headers.host}${req.url}:`, err);
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated

// Return generic error to client
if (isResponseLike(res)) {
if (!res.headersSent) {
const statusCode = getStatusCode((err as unknown as any).code);
res.writeHead(statusCode);
}

const host = req.headers && req.headers.host;
res.end(`Error occurred while trying to proxy: ${sanitize(host)}${sanitize(req.url)}`);
res.end('UPSTREAM_ERROR');
} else if (isSocketLike(res)) {
res.destroy();
}
Expand Down