Skip to content

Commit

Permalink
Updated variables
Browse files Browse the repository at this point in the history
  • Loading branch information
changesbyjames committed Nov 15, 2024
1 parent fb02c72 commit f9e693c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
23 changes: 10 additions & 13 deletions census/api/src/services/auth/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,17 @@ export const createSignInRequest = (path: string, state: string) => {

export const getHost = () => {
const { variables } = useEnvironment();
const host = (() => {
if (variables.NODE_ENV === 'development') {
return `http://${variables.HOST}:${variables.PORT}`;
}
if (variables.API_URL) {
return variables.API_URL;
}
if (variables.CONTAINER_APP_NAME && variables.CONTAINER_APP_ENV_DNS_SUFFIX) {
return `https://${variables.CONTAINER_APP_NAME}.${variables.CONTAINER_APP_ENV_DNS_SUFFIX}`;
}
})();
if (variables.NODE_ENV === 'development') {
return `http://${variables.HOST}:${variables.PORT}`;
}
if (variables.API_URL) {
return variables.API_URL;
}
if (variables.CONTAINER_APP_NAME && variables.CONTAINER_APP_ENV_DNS_SUFFIX) {
return `https://${variables.CONTAINER_APP_NAME}.${variables.CONTAINER_APP_ENV_DNS_SUFFIX}`;
}

if (!host) throw new Error('No host found');
return host;
throw new Error('No host found');
};

export const exchangeCodeForToken = async (path: string, code: string) => {
Expand Down
2 changes: 1 addition & 1 deletion census/api/src/utils/env/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const config = z.object({
TWITCH_CLIENT_ID: z.string(),
TWITCH_CLIENT_SECRET: z.string(),

NODE_ENV: z.enum(['development', 'production']).default('development'),
NODE_ENV: z.enum(['development', 'production']),
HOST: z.string(),
PORT: z.coerce.number(),

Expand Down

0 comments on commit f9e693c

Please sign in to comment.