Skip to content

Commit

Permalink
feat(api/utils): create getBaseUrl method
Browse files Browse the repository at this point in the history
  • Loading branch information
JowiAoun committed Sep 29, 2024
1 parent d7a80bb commit 02b8980
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions libs/utils/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export * from './lib/utils'

export * from './url'
11 changes: 11 additions & 0 deletions libs/utils/src/url.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* This function gets the base URL of the current environment.
* @returns The base URL.
*/
export function getBaseUrl() {
if (typeof window !== 'undefined') {
return window.location.origin
}

return `http://localhost:${String(3000)}`
}

0 comments on commit 02b8980

Please sign in to comment.