upd: added env for api & websocket urls

This commit is contained in:
Sergey Yarkov 2022-06-04 00:31:09 +03:00
parent 3cd2d0eeba
commit d366c05d55
5 changed files with 9 additions and 3 deletions

View File

@ -6,6 +6,11 @@ WORKDIR /home/app
COPY package*.json ./ COPY package*.json ./
RUN npm install RUN npm install
COPY . . COPY . .
# Get build arguments and set env variables
ARG API_URL
ARG WS_URL
ENV VITE_API_URL=${API_URL}
ENV VITE_WS_URL=${WS_URL}
RUN npm run build RUN npm run build
FROM ${NGINX_IMAGE} as production FROM ${NGINX_IMAGE} as production

View File

@ -2,7 +2,7 @@ import { AxiosRequestConfig } from 'axios';
import * as constants from '@educt/constants'; import * as constants from '@educt/constants';
const apiConfig: AxiosRequestConfig = { const apiConfig: AxiosRequestConfig = {
baseURL: `${constants.BACKEND_URL}/api/`, baseURL: `${constants.BACKEND_URL}/`,
responseType: 'json', responseType: 'json',
withCredentials: true, withCredentials: true,
}; };

View File

@ -84,7 +84,7 @@ const LessonForm: React.FC<LessonFormPropsType> = ({
<VideoUploader <VideoUploader
onChange={file => onChange(file)} onChange={file => onChange(file)}
file={file} file={file}
preloadedVideoUrl={constants.BACKEND_URL + preloadedVideo?.url} preloadedVideoUrl={preloadedVideo && constants.BACKEND_URL + preloadedVideo.url}
/> />
)} )}
/> />

View File

@ -1,2 +1,2 @@
export const BACKEND_URL = import.meta.env.VITE_API_URL || 'http://localhost:3333'; export const BACKEND_URL = import.meta.env.VITE_API_URL || 'http://localhost:3333';
export const WS_URL = 'ws://localhost:3333'; export const WS_URL = import.meta.env.VITE_WS_URL || 'ws://localhost:3333';

1
src/env.d.ts vendored
View File

@ -2,6 +2,7 @@
interface ImportMetaEnv { interface ImportMetaEnv {
readonly VITE_API_URL?: string | undefined; readonly VITE_API_URL?: string | undefined;
readonly VITE_WS_URL?: string | undefined;
} }
interface ImportMeta { interface ImportMeta {