From f0ed64d0dedaef1073cfd44420081874fdcd91ba Mon Sep 17 00:00:00 2001 From: Janis Hutz Date: Tue, 22 Sep 2026 08:04:31 +0200 Subject: [PATCH] feat: imports, retrievable backend URL --- browser/package.json | 2 +- browser/src/request.ts | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/browser/package.json b/browser/package.json index 8cec41e..2aeac2b 100644 --- a/browser/package.json +++ b/browser/package.json @@ -1,6 +1,6 @@ { "name": "@janishutz/oidc-login-sdk-browser", - "version": "1.2.0", + "version": "1.3.1", "description": "SDK to communicate with and log into a backend running express-openid-connect", "homepage": "https://github.com/janishutz/oidc-login-sdk#readme", "bugs": { diff --git a/browser/src/request.ts b/browser/src/request.ts index 0bfebb2..fe01da8 100644 --- a/browser/src/request.ts +++ b/browser/src/request.ts @@ -1,7 +1,6 @@ -import { +import config, { AuthErrorResolution -} from './dtype.js'; -import config from './config.js'; +} from './config.js'; import { login } from './auth.js'; @@ -55,6 +54,14 @@ const deleteRequest = async ( url: string, authErrorResolution?: AuthErrorResolu }, authErrorResolution ); }; +/** + * Retrieve the configured backend URL + * @returns The URL to the backend + */ +const getBackendURL = () => { + return config.get().backendURL; +}; + const wrapper = async ( url: string, opts: RequestInit, authErrorResolution?: AuthErrorResolution ): Promise => { const res = await fetch( config.get().backendURL + url, { 'redirect': 'manual', @@ -75,7 +82,7 @@ const wrapper = async ( url: string, opts: RequestInit, authErrorResolution?: Au } }; -const handleUnauth = ( authErrorResolution: AuthErrorResolution ) => { +const handleUnauth = ( authErrorResolution?: AuthErrorResolution ) => { if ( config.get().authErrorEvent ) { document.dispatchEvent( new CustomEvent( 'autherror' ) ); } @@ -90,5 +97,6 @@ const handleUnauth = ( authErrorResolution: AuthErrorResolution ) => { export default { get, post, - 'delete': deleteRequest + 'delete': deleteRequest, + getBackendURL };