Skip to content

Commit ceb42cb

Browse files
authored
feat: support relative baseUrls (open-feature#950)
Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
1 parent 4aec2ef commit ceb42cb

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

libs/providers/ofrep-web/src/lib/ofrep-web-provider.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,6 @@ export class OFREPWebProvider implements Provider {
6464
private _pollingIntervalId?: number;
6565

6666
constructor(options: OFREPWebProviderOptions, logger?: Logger) {
67-
try {
68-
// Cannot use URL.canParse as it is only available from Node 19.x
69-
new URL(options.baseUrl);
70-
} catch {
71-
throw new Error(`The given OFREP URL "${options.baseUrl}" is not a valid URL.`);
72-
}
73-
7467
this._options = options;
7568
this._logger = logger;
7669
this._etag = null;

libs/shared/ofrep-core/src/lib/provider/ofrep-provider-options.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,26 @@ export type HttpHeaderMap = Record<string, string>;
55
export type HttpHeaders = HttpHeaderList | HttpHeaderMap;
66

77
export type OFREPProviderBaseOptions = {
8+
/**
9+
* Base URL for OFREP requests. Relative paths are supported.
10+
* For example, if your OFREP instance is available at
11+
* "https://host.com/path/{ofrep-api}" , you should set this to
12+
* "https://host.com/path" or "/path" (if your app and OFREP instance
13+
* share the same origin).
14+
*/
815
baseUrl: string;
16+
/**
17+
* Optional fetch implementation
18+
*/
919
fetchImplementation?: FetchAPI;
20+
/**
21+
* Optional Headers supplier function.
22+
* @returns HttpHeaders
23+
*/
1024
headersFactory?: () => HttpHeaders;
25+
/**
26+
* Optional static headers.
27+
*/
1128
headers?: HttpHeaders;
1229
};
1330

0 commit comments

Comments
 (0)