Skip to content

Commit

Permalink
Fix non-working environment variable import
Browse files Browse the repository at this point in the history
  • Loading branch information
monsieurswag committed Nov 29, 2024
1 parent f89ed6c commit f6c62ed
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
2 changes: 0 additions & 2 deletions frontend/src/lib/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ export const BASE_API_URL = `${
: 'http://localhost:8000/api'
}`;

export const CI_TEST: boolean = Object.hasOwn(env, 'CI_TEST');

export const ALLAUTH_API_URL = `${BASE_API_URL}/_allauth/app/v1`;

export const BACKEND_API_EXPOSED_URL = `${
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/lib/utils/env_constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import * as env from '$env/static/private';

export const CI_TEST: boolean = Object.hasOwn(env, 'CI_TEST');
6 changes: 3 additions & 3 deletions frontend/src/routes/(app)/+page.server.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { redirect } from '@sveltejs/kit';
import type { PageServerLoad } from './$types';
import { CI_TEST } from '$lib/utils/constants';
import { CI_TEST } from '$lib/utils/env_constants';

const redirectURL = CI_TEST ? '/analytics' : '/analytics?refresh=1';
console.log(`[NEW_REDIRECT:1] ${CI_TEST}`);
console.log(`[CI_TEST_VALUE:1] ${CI_TEST}`);

export const load: PageServerLoad = async () => {
console.log(`[NEW_REDIRECT:2] ${CI_TEST}`);
console.log(`[CI_TEST_VALUE:2] ${CI_TEST}`);
redirect(301, redirectURL);
};
4 changes: 2 additions & 2 deletions frontend/src/routes/(authentication)/login/+page.server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { getSecureRedirect } from '$lib/utils/helpers';

import { ALLAUTH_API_URL, BASE_API_URL, CI_TEST } from '$lib/utils/constants';
import { ALLAUTH_API_URL, BASE_API_URL } from '$lib/utils/constants';
import { CI_TEST } from '$lib/utils/env_constants';
import { loginSchema } from '$lib/utils/schemas';
import type { LoginRequestBody } from '$lib/utils/types';
import { fail, redirect, type Actions } from '@sveltejs/kit';
Expand Down Expand Up @@ -132,7 +133,6 @@ export const actions: Actions = {

const next = url.searchParams.get('next') || '/';
const redirectURL = getSecureRedirect(next) + (CI_TEST ? '' : '?refresh=1');
console.log(`[NEW_REDIRECT:3] ${redirectURL}`);
redirect(302, redirectURL);
},
mfaAuthenticate: async (event) => {
Expand Down

0 comments on commit f6c62ed

Please sign in to comment.