Skip to content

Commit 715d6b2

Browse files
move VEDA_BACKEND_URL to config (#146)
1 parent 3b2dc3b commit 715d6b2

File tree

5 files changed

+15
-7
lines changed

5 files changed

+15
-7
lines changed

__tests__/hooks/useCogValidation.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,9 @@ describe('useCogValidation', () => {
9595
});
9696

9797
expect(isValid!).toBe(true);
98+
const { VEDA_BACKEND_URL } = await import('@/config/env');
9899
expect(global.fetch).toHaveBeenCalledWith(
99-
'https://staging.openveda.cloud/api/raster/cog/validate?strict=false&url=http%3A%2F%2Fexample.com%2Ffile.tif'
100+
`${VEDA_BACKEND_URL}/raster/cog/validate?strict=false&url=http%3A%2F%2Fexample.com%2Ffile.tif`
100101
);
101102
});
102103

@@ -117,8 +118,9 @@ describe('useCogValidation', () => {
117118
});
118119

119120
expect(isValid!).toBe(true);
121+
const { VEDA_BACKEND_URL } = await import('@/config/env');
120122
expect(global.fetch).toHaveBeenCalledWith(
121-
'https://staging.openveda.cloud/api/raster/cog/validate?strict=false&url=http%3A%2F%2Fexample.com%2Ffile1.tif'
123+
`${VEDA_BACKEND_URL}/raster/cog/validate?strict=false&url=http%3A%2F%2Fexample.com%2Ffile1.tif`
122124
);
123125
});
124126

components/COGViewer/COGControlsForm.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,8 @@ const COGControlsForm: React.FC<COGControlsFormProps> = ({
9696

9797
const getColorMaps = async () => {
9898
try {
99-
const response = await fetch(
100-
'https://staging.openveda.cloud/api/raster/colorMaps'
101-
);
99+
const { VEDA_BACKEND_URL } = await import('@/config/env');
100+
const response = await fetch(`${VEDA_BACKEND_URL}/raster/colorMaps`);
102101
const data = await response.json();
103102
setColorMapsList(['Internal', ...data.colorMaps]);
104103
} catch (error) {

components/rjsf-components/TestableUrlWidget.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { WidgetProps } from '@rjsf/utils';
2+
import { VEDA_BACKEND_URL } from '@/config/env';
23
import Input from 'antd/lib/input';
34
import Button from 'antd/lib/button';
45
import Typography from 'antd/lib/typography';
@@ -40,7 +41,7 @@ export const TestableUrlWidget = ({
4041

4142
setValidationState('loading');
4243
const encodedUrl = encodeURIComponent(inputValue);
43-
const validationApiUrl = `https://staging.openveda.cloud/api/raster/cog/validate?strict=false&url=${encodedUrl}`;
44+
const validationApiUrl = `${VEDA_BACKEND_URL}/raster/cog/validate?strict=false&url=${encodedUrl}`;
4445

4546
try {
4647
const response = await fetch(validationApiUrl);

config/env.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ interface EnvConfig {
1010
AWS_REGION: string;
1111
NEXT_PUBLIC_AWS_S3_BUCKET_NAME: string;
1212
ADDITIONAL_LOGO: string;
13+
VEDA_BACKEND_URL: string;
1314
}
1415

1516
const profiles: Record<AppEnv, EnvConfig> = {
@@ -20,6 +21,7 @@ const profiles: Record<AppEnv, EnvConfig> = {
2021
AWS_REGION: 'us-west-2',
2122
NEXT_PUBLIC_AWS_S3_BUCKET_NAME: 'veda-thumbnails',
2223
ADDITIONAL_LOGO: '',
24+
VEDA_BACKEND_URL: 'https://staging.openveda.cloud/api',
2325
},
2426
veda: {
2527
OWNER: 'nasa-impact',
@@ -28,6 +30,7 @@ const profiles: Record<AppEnv, EnvConfig> = {
2830
AWS_REGION: 'us-west-2',
2931
NEXT_PUBLIC_AWS_S3_BUCKET_NAME: 'veda-thumbnails',
3032
ADDITIONAL_LOGO: '',
33+
VEDA_BACKEND_URL: 'https://staging.openveda.cloud/api',
3134
},
3235
disasters: {
3336
OWNER: 'Disasters-Learning-Portal',
@@ -36,6 +39,7 @@ const profiles: Record<AppEnv, EnvConfig> = {
3639
AWS_REGION: 'us-west-2',
3740
NEXT_PUBLIC_AWS_S3_BUCKET_NAME: 'veda-thumbnails',
3841
ADDITIONAL_LOGO: 'disasters',
42+
VEDA_BACKEND_URL: 'https://staging.openveda.cloud/api',
3943
},
4044
};
4145

@@ -46,3 +50,4 @@ const getAppEnv = (): AppEnv => {
4650
};
4751

4852
export const cfg: EnvConfig = profiles[getAppEnv()];
53+
export const VEDA_BACKEND_URL = cfg.VEDA_BACKEND_URL;

hooks/useCogValidation.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { useState } from 'react';
2+
import { VEDA_BACKEND_URL } from '@/config/env';
23

34
interface UseCogValidationReturn {
45
isCogValidationModalVisible: boolean;
@@ -20,7 +21,7 @@ export const useCogValidation = (): UseCogValidationReturn => {
2021
if (!url) return true; // Skip validation if no URL provided
2122

2223
const encodedUrl = encodeURIComponent(url);
23-
const validationApiUrl = `https://staging.openveda.cloud/api/raster/cog/validate?strict=false&url=${encodedUrl}`;
24+
const validationApiUrl = `${VEDA_BACKEND_URL}/raster/cog/validate?strict=false&url=${encodedUrl}`;
2425

2526
try {
2627
const response = await fetch(validationApiUrl);

0 commit comments

Comments
 (0)