Skip to content

Instantly share code, notes, and snippets.

@antonkalik
Created March 27, 2024 21:10
Show Gist options
  • Save antonkalik/30956154bb26e2e82d8105f99e620502 to your computer and use it in GitHub Desktop.
Save antonkalik/30956154bb26e2e82d8105f99e620502 to your computer and use it in GitHub Desktop.
Get Host
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