Skip to content

Commit

Permalink
feat: support new optional ECOMCLIENT_API_PASSPORT_IDENTITY env for…
Browse files Browse the repository at this point in the history
… passport on identity endpoints

useful to separate passport api proxy and auth flow endpoints (v2)
  • Loading branch information
leomp12 committed Mar 22, 2024
1 parent db4146d commit 9363e7c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/lib/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export const IS_BROWSER = Boolean(typeof window === 'object' && window !== null
export const API_STORE = env.ECOMCLIENT_API_STORE || 'https://api.e-com.plus/v1/'
export const API_STORE_CACHE = env.ECOMCLIENT_API_STORE_CACHE || 'https://ioapi.ecvol.com/:id/v1/'
export const API_PASSPORT = env.ECOMCLIENT_API_PASSPORT || 'https://passport.e-com.plus/v1/'
export const API_PASSPORT_IDENTITY = env.ECOMCLIENT_API_PASSPORT_IDENTITY
export const API_SEARCH = env.ECOMCLIENT_API_SEARCH || 'https://apx-search.e-com.plus/api/v1/'
export const API_MODULES = env.ECOMCLIENT_API_MODULES || 'https://apx-mods.e-com.plus/api/v1/'
export const API_STOREFRONT = env.ECOMCLIENT_API_STOREFRONT || 'https://iostorefront.ecvol.com/api/v1/'
Expand Down
5 changes: 4 additions & 1 deletion src/methods/passport.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { _config } from '@ecomplus/utils'
import { API_PASSPORT } from './../lib/constants'
import { API_PASSPORT_IDENTITY, API_PASSPORT } from './../lib/constants'
import request from './../lib/request'

const passport = ({
Expand All @@ -12,6 +12,9 @@ const passport = ({
axiosConfig
}) => {
let baseURL = API_PASSPORT
if (API_PASSPORT_IDENTITY && /\/(identify|token|oauth-providers)(\.json)?$/.test(url)) {
baseURL = API_PASSPORT_IDENTITY
}
if (!url.startsWith('http') && !url.startsWith('/' + storeId)) {
// set Store ID on URL
baseURL += storeId
Expand Down

0 comments on commit 9363e7c

Please sign in to comment.