Skip to content

Commit

Permalink
Update api-proxy to use BACKEND_PORT env var (opendatahub-io#132)
Browse files Browse the repository at this point in the history
  • Loading branch information
cfchase authored Mar 9, 2022
1 parent e2156bb commit c5f98e7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 17 deletions.
13 changes: 0 additions & 13 deletions backend/src/routes/api/cluster-settings/index.ts
Original file line number Diff line number Diff line change
@@ -1,37 +1,24 @@
import { FastifyInstance, FastifyReply, FastifyRequest } from 'fastify';
import { DEV_MODE } from '../../../utils/constants';
import { addCORSHeader } from '../../../utils/responseUtils';
import { getClusterSettings, updateClusterSettings } from './clusterSettingsUtils';

export default async (fastify: FastifyInstance): Promise<void> => {
fastify.get('/', async (request: FastifyRequest, reply: FastifyReply) => {
return getClusterSettings(fastify)
.then((res) => {
if (DEV_MODE) {
addCORSHeader(request, reply);
}
return res;
})
.catch((res) => {
if (DEV_MODE) {
addCORSHeader(request, reply);
}
reply.send(res);
});
});

fastify.get('/update', async (request: FastifyRequest, reply: FastifyReply) => {
return updateClusterSettings(fastify, request)
.then((res) => {
if (DEV_MODE) {
addCORSHeader(request, reply);
}
return res;
})
.catch((res) => {
if (DEV_MODE) {
addCORSHeader(request, reply);
}
reply.send(res);
});
});
Expand Down
3 changes: 2 additions & 1 deletion frontend/config/webpack.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const COMMON_DIR = process.env._ODH_COMMON_DIR;
const DIST_DIR = process.env._ODH_DIST_DIR;
const HOST = process.env._ODH_HOST;
const PORT = process.env._ODH_PORT;
const BACKEND_PORT = process.env.BACKEND_PORT || 8080;

module.exports = merge(
{
Expand All @@ -35,7 +36,7 @@ module.exports = merge(
open: true,
stats: 'errors-only',
proxy: {
'/api': 'http://localhost:8080',
'/api': `http://localhost:${BACKEND_PORT}`,
},
},
module: {
Expand Down
5 changes: 2 additions & 3 deletions frontend/src/services/clusterSettingsService.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import axios from 'axios';
import { ClusterSettings } from '../types';
import { getBackendURL } from '../utilities/utils';

export const fetchClusterSettings = (): Promise<ClusterSettings> => {
const url = getBackendURL('/api/cluster-settings');
const url = '/api/cluster-settings';
return axios
.get(url)
.then((response) => {
Expand All @@ -17,7 +16,7 @@ export const fetchClusterSettings = (): Promise<ClusterSettings> => {
export const updateClusterSettings = (
settings: ClusterSettings,
): Promise<{ success: boolean; error: string }> => {
const url = getBackendURL('/api/cluster-settings/update');
const url = '/api/cluster-settings/update';
const updateParams = new URLSearchParams();

updateParams.set('pvcSize', `${settings.pvcSize}`);
Expand Down

0 comments on commit c5f98e7

Please sign in to comment.