mirror of
https://github.com/outline/outline.git
synced 2026-06-13 11:25:03 +03:00
fix: Private IP lookup should be invalid request rather than internal error (#12592)
This commit is contained in:
@@ -11,7 +11,7 @@ import nodeFetch, {
|
||||
import { getProxyForUrl } from "proxy-from-env";
|
||||
import tunnelAgent, { type TunnelAgent } from "tunnel-agent";
|
||||
import env from "@server/env";
|
||||
import { InternalError } from "@server/errors";
|
||||
import { InvalidRequestError } from "@server/errors";
|
||||
import Logger from "@server/logging/Logger";
|
||||
import { capitalize } from "es-toolkit/compat";
|
||||
import {
|
||||
@@ -184,9 +184,11 @@ export default async function fetch(
|
||||
if (err.name === "AbortError") {
|
||||
throw new Error(`Request timeout after ${timeout}ms`);
|
||||
}
|
||||
if (!env.isCloudHosted && err.message?.startsWith("DNS lookup")) {
|
||||
throw InternalError(
|
||||
`${err.message}\n\nTo allow this request, add the IP address or CIDR range to the ALLOWED_PRIVATE_IP_ADDRESSES environment variable.`
|
||||
if (err.message?.startsWith("DNS lookup")) {
|
||||
throw InvalidRequestError(
|
||||
env.isCloudHosted
|
||||
? err.message
|
||||
: `${err.message}\n\nTo allow this request, add the IP address or CIDR range to the ALLOWED_PRIVATE_IP_ADDRESSES environment variable.`
|
||||
);
|
||||
}
|
||||
throw err;
|
||||
|
||||
Reference in New Issue
Block a user