backstage
126 строк · 4.6 Кб
1/*
2* Copyright 2020 The Backstage Authors
3*
4* Licensed under the Apache License, Version 2.0 (the "License");
5* you may not use this file except in compliance with the License.
6* You may obtain a copy of the License at
7*
8* http://www.apache.org/licenses/LICENSE-2.0
9*
10* Unless required by applicable law or agreed to in writing, software
11* distributed under the License is distributed on an "AS IS" BASIS,
12* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13* See the License for the specific language governing permissions and
14* limitations under the License.
15*/
16
17export interface Config {
18proxy?: {
19/**
20* Rather than failing to start up, the proxy backend will instead just warn on invalid endpoints.
21*/
22skipInvalidProxies?: boolean;
23
24/**
25* Revive request bodies that have already been consumed by earlier middleware.
26*/
27reviveConsumedRequestBodies?: boolean;
28
29/**
30* A list of forwarding-proxies. Each key is a route to match,
31* below the prefix that the proxy plugin is mounted on. It must
32* start with a '/'.
33*/
34endpoints?: {
35[key: string]:
36| string
37| {
38/**
39* Target of the proxy. Url string to be parsed with the url module.
40*/
41target: string;
42/**
43* Object with extra headers to be added to target requests.
44*/
45headers?: {
46/** @visibility secret */
47Authorization?: string;
48/** @visibility secret */
49authorization?: string;
50/** @visibility secret */
51'X-Api-Key'?: string;
52/** @visibility secret */
53'x-api-key'?: string;
54[key: string]: string | undefined;
55};
56/**
57* Changes the origin of the host header to the target URL. Default: true.
58*/
59changeOrigin?: boolean;
60/**
61* Rewrite target's url path. Object-keys will be used as RegExp to match paths.
62* If pathRewrite is not specified, it is set to a single rewrite that removes the entire prefix and route.
63*/
64pathRewrite?: { [regexp: string]: string };
65/**
66* Limit the forwarded HTTP methods, for example allowedMethods: ['GET'] to enforce read-only access.
67*/
68allowedMethods?: string[];
69/**
70* Limit the forwarded HTTP methods. By default, only the headers that are considered safe for CORS
71* and headers that are set by the proxy will be forwarded.
72*/
73allowedHeaders?: string[];
74};
75};
76} & {
77/**
78* This was the legacy way of expressing proxies, and is now deprecated. We
79* keep it around in the config schema, to ensure that legacy setups still
80* have properly secret-marked values so that they get redacted.
81*
82* TODO(freben): Remove this in the future (suggestion: after 2024-03-01)
83* when people likely have moved off of this format.
84*/
85[key: string]:
86| string
87| {
88/**
89* Target of the proxy. Url string to be parsed with the url module.
90*/
91target: string;
92/**
93* Object with extra headers to be added to target requests.
94*/
95headers?: {
96/** @visibility secret */
97Authorization?: string;
98/** @visibility secret */
99authorization?: string;
100/** @visibility secret */
101'X-Api-Key'?: string;
102/** @visibility secret */
103'x-api-key'?: string;
104[key: string]: string | undefined;
105};
106/**
107* Changes the origin of the host header to the target URL. Default: true.
108*/
109changeOrigin?: boolean;
110/**
111* Rewrite target's url path. Object-keys will be used as RegExp to match paths.
112* If pathRewrite is not specified, it is set to a single rewrite that removes the entire prefix and route.
113*/
114pathRewrite?: { [regexp: string]: string };
115/**
116* Limit the forwarded HTTP methods, for example allowedMethods: ['GET'] to enforce read-only access.
117*/
118allowedMethods?: string[];
119/**
120* Limit the forwarded HTTP methods. By default, only the headers that are considered safe for CORS
121* and headers that are set by the proxy will be forwarded.
122*/
123allowedHeaders?: string[];
124};
125};
126}
127