Created
March 27, 2024 21:10
-
-
Save antonkalik/30956154bb26e2e82d8105f99e620502 to your computer and use it in GitHub Desktop.
Get Host
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
import * as dotenv from 'dotenv'; | |
import process from 'process'; | |
dotenv.config(); | |
export const getHost = (): string => { | |
const isProduction = process.env.NODE_ENV === 'production'; | |
const protocol = isProduction ? 'https' : 'http'; | |
const port = isProduction ? '' : `:${process.env.CLIENT_PORT}`; | |
return `${protocol}://${process.env.WEB_HOST}${port}`; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment