proxy-backend: deprecate root proxy config, move to proxy.endpoints instead

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2023-08-02 16:25:19 +02:00
parent f1d32fb998
commit 7daf65bfcf
4 changed files with 137 additions and 78 deletions
+56 -44
View File
@@ -15,51 +15,63 @@
*/
export interface Config {
/**
* A list of forwarding-proxies. Each key is a route to match,
* below the prefix that the proxy plugin is mounted on. It must
* start with a '/'.
*/
proxy?: {
[key: string]:
| string
| {
/**
* Target of the proxy. Url string to be parsed with the url module.
*/
target: string;
/**
* Object with extra headers to be added to target requests.
*/
headers?: {
/** @visibility secret */
Authorization?: string;
/** @visibility secret */
authorization?: string;
/** @visibility secret */
'X-Api-Key'?: string;
/** @visibility secret */
'x-api-key'?: string;
[key: string]: string | undefined;
/**
* Rather than failing to start up, the proxy backend will instead just warn on invalid endpoints.
*/
skipInvalidProxies?: boolean;
/**
* Revive request bodies that have already been consumed by earlier middleware.
*/
reviveConsumedRequestBodies?: boolean;
/**
* A list of forwarding-proxies. Each key is a route to match,
* below the prefix that the proxy plugin is mounted on. It must
* start with a '/'.
*/
endpoints?: {
[key: string]:
| string
| {
/**
* Target of the proxy. Url string to be parsed with the url module.
*/
target: string;
/**
* Object with extra headers to be added to target requests.
*/
headers?: {
/** @visibility secret */
Authorization?: string;
/** @visibility secret */
authorization?: string;
/** @visibility secret */
'X-Api-Key'?: string;
/** @visibility secret */
'x-api-key'?: string;
[key: string]: string | undefined;
};
/**
* Changes the origin of the host header to the target URL. Default: true.
*/
changeOrigin?: boolean;
/**
* Rewrite target's url path. Object-keys will be used as RegExp to match paths.
* If pathRewrite is not specified, it is set to a single rewrite that removes the entire prefix and route.
*/
pathRewrite?: { [regexp: string]: string };
/**
* Limit the forwarded HTTP methods, for example allowedMethods: ['GET'] to enforce read-only access.
*/
allowedMethods?: string[];
/**
* Limit the forwarded HTTP methods. By default, only the headers that are considered safe for CORS
* and headers that are set by the proxy will be forwarded.
*/
allowedHeaders?: string[];
};
/**
* Changes the origin of the host header to the target URL. Default: true.
*/
changeOrigin?: boolean;
/**
* Rewrite target's url path. Object-keys will be used as RegExp to match paths.
* If pathRewrite is not specified, it is set to a single rewrite that removes the entire prefix and route.
*/
pathRewrite?: { [regexp: string]: string };
/**
* Limit the forwarded HTTP methods, for example allowedMethods: ['GET'] to enforce read-only access.
*/
allowedMethods?: string[];
/**
* Limit the forwarded HTTP methods. By default, only the headers that are considered safe for CORS
* and headers that are set by the proxy will be forwarded.
*/
allowedHeaders?: string[];
};
};
};
}