From 6c766fc651a78bab5c177ce2ebd7d22510a3b24f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Mili=C4=87?= Date: Mon, 25 Nov 2024 11:59:00 +0100 Subject: [PATCH] feature/Enable API Explorer II for OBP API split portal/API mode --- .env.example | 8 ++++++++ package.json | 2 +- server/middlewares/OauthRequestTokenMiddleware.ts | 3 ++- src/components/HeaderNav.vue | 2 +- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.env.example b/.env.example index 121a98a..6519887 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,12 @@ VITE_OBP_API_HOST=https://apisandbox.openbankproject.com + +### OBP-API mode ################################### +# If OBP-API split to two instances, eg: apis,portal +# Then API_Explorer need to set two api hosts: api_hostname and this api_portal_hostname, for all Rest Apis will call api_hostname +# but for all the portal home page link, we need to use this props. If do not set this, it will use api_hostname value instead. +VITE_OBP_API_PORTAL_HOST=https://apisandbox.openbankproject.com +#################################################################################### + VITE_OBP_API_VERSION=v5.1.0 VITE_OBP_API_MANAGER_HOST=https://apimanagersandbox.openbankproject.com VITE_OBP_API_EXPLORER_HOST=http://localhost:5173 diff --git a/package.json b/package.json index a246f5b..69dc254 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "api-explorer", - "version": "1.0.22", + "version": "1.0.23", "private": true, "scripts": { "dev": "vite & ts-node server/app.ts", diff --git a/server/middlewares/OauthRequestTokenMiddleware.ts b/server/middlewares/OauthRequestTokenMiddleware.ts index 8ca866a..39d40cf 100644 --- a/server/middlewares/OauthRequestTokenMiddleware.ts +++ b/server/middlewares/OauthRequestTokenMiddleware.ts @@ -35,7 +35,8 @@ export default class OauthRequestTokenMiddleware implements ExpressMiddlewareInt constructor(private oauthInjectedService: OauthInjectedService) {} use(request: Request, response: Response): any { - const apiHost = process.env.VITE_OBP_API_HOST + const apiHost = process.env.VITE_OBP_API_PORTAL_HOST || process.env.VITE_OBP_API_HOST; + console.debug('OauthRequestTokenMiddleware - API Host:', apiHost); const oauthService = this.oauthInjectedService const consumer = oauthService.getConsumer() consumer.getOAuthRequestToken((error: any, oauthTokenKey: string, oauthTokenSecret: string) => { diff --git a/src/components/HeaderNav.vue b/src/components/HeaderNav.vue index afedbec..781a35c 100644 --- a/src/components/HeaderNav.vue +++ b/src/components/HeaderNav.vue @@ -41,7 +41,7 @@ import { obpApiActiveVersionsKey, obpGroupedMessageDocsKey, obpMyCollectionsEndp const route = useRoute() const router = useRouter() -const obpApiHost = ref(import.meta.env.VITE_OBP_API_HOST) +const obpApiHost = ref(import.meta.env.VITE_OBP_API_PORTAL_HOST || import.meta.env.VITE_OBP_API_HOST); const obpApiManagerHost = ref(import.meta.env.VITE_OBP_API_MANAGER_HOST) const loginUsername = ref('') const logoffurl = ref('')