-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GEN-1745]: fix API base URL for production events (attempt to fix SS…
…E) (#1795)
- Loading branch information
1 parent
67af0aa
commit 733b4a8
Showing
2 changed files
with
17 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,19 @@ | ||
'use client'; | ||
const ENV = process.env.NODE_ENV; | ||
const IS_PRODUCTION = ENV === 'production'; | ||
const IS_PROD = process.env.NODE_ENV === 'production'; | ||
|
||
// Define base URLs depending on the environment and rendering context | ||
const LOCAL_API_BASE = 'http://localhost:8085'; | ||
//we use localhost:8085 as the base URL for server environment | ||
const PRODUCTION_GQL_API_BASE = IS_PRODUCTION && typeof window !== 'undefined' ? `${window.location.origin}/graphql` : `${LOCAL_API_BASE}/graphql`; | ||
const API_BASE_URL = IS_PRODUCTION ? PRODUCTION_GQL_API_BASE : `${LOCAL_API_BASE}/graphql`; | ||
// set base URLs for all environments | ||
const DEV_API_URL = 'http://localhost:8085'; | ||
const PROD_API_URL = typeof window !== 'undefined' ? window.location.origin : 'http://localhost:3000'; | ||
|
||
// Define endpoints based on the base URL | ||
// construct final base URL based on environment | ||
const API_BASE_URL = IS_PROD ? PROD_API_URL : DEV_API_URL; | ||
|
||
// add paths to base URL | ||
const API = { | ||
BASE_URL: API_BASE_URL, | ||
EVENTS: `${IS_PRODUCTION ? '/' : LOCAL_API_BASE}/api/events`, | ||
GRAPHQL: `${API_BASE_URL}/graphql`, | ||
EVENTS: `${API_BASE_URL}/api/events`, | ||
}; | ||
|
||
// Centralize external links | ||
export const DOCS_LINK = 'https://docs.odigos.io'; | ||
const DOCS_LINK = 'https://docs.odigos.io'; | ||
|
||
// Export modules | ||
export { API }; | ||
export { API, DOCS_LINK }; |