-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1592772
commit 16e5722
Showing
1 changed file
with
9 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,12 @@ | ||
const BASE = import.meta.env.VITE_API_HOST || 'http://localhost' | ||
const PORT = import.meta.env.VITE_API_PORT || '81' | ||
const PREFIX = import.meta.env.VITE_API_PREFIX || '' | ||
export const API_URL = BASE + ':' + PORT + PREFIX | ||
|
||
|
||
const isDefaultPort = (url, port) => { | ||
const isHttp = url.startsWith('http://') && port === '80'; | ||
const isHttps = url.startsWith('https://') && port === '443'; | ||
return isHttp || isHttps; | ||
}; | ||
|
||
export const API_URL = isDefaultPort(BASE, PORT) ? BASE + PREFIX : BASE + ':' + PORT + PREFIX; |