-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5899 from entur/fix-graphql-request-breaking-chan…
…ge-in-url Fix debug client after breaking change in dependency graphql-request
- Loading branch information
Showing
3 changed files
with
17 additions
and
7 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
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const endpoint = import.meta.env.VITE_API_URL; | ||
|
||
export const getApiUrl = () => { | ||
try { | ||
// the URL constructor will throw exception if endpoint is not a valid URL, | ||
// e.g. if it is a relative path | ||
new URL(endpoint); | ||
return endpoint; | ||
} catch (e) { | ||
return `${window.location.origin}${endpoint}`; | ||
} | ||
}; |