mirror of
https://github.com/sergeyyarkov/educt-client.git
synced 2026-10-11 18:29:15 +03:00
fix: api url env
This commit is contained in:
parent
57bb798eff
commit
3cd2d0eeba
1
.gitignore
vendored
1
.gitignore
vendored
@ -4,3 +4,4 @@ stats.html
|
|||||||
dist
|
dist
|
||||||
dist-ssr
|
dist-ssr
|
||||||
*.local
|
*.local
|
||||||
|
.env
|
||||||
|
|||||||
@ -1,2 +0,0 @@
|
|||||||
export const BACKEND_URL = 'http://localhost:3333';
|
|
||||||
export const WS_URL = 'ws://localhost:3333';
|
|
||||||
@ -1,5 +1,5 @@
|
|||||||
server {
|
server {
|
||||||
listen 80;
|
listen 5000;
|
||||||
location / {
|
location / {
|
||||||
root /usr/share/nginx/html;
|
root /usr/share/nginx/html;
|
||||||
index index.html index.htm;
|
index index.html index.htm;
|
||||||
|
|||||||
5784
package-lock.json
generated
5784
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
|||||||
import { AxiosRequestConfig } from 'axios';
|
import { AxiosRequestConfig } from 'axios';
|
||||||
import * as constants from '../constants';
|
import * as constants from '@educt/constants';
|
||||||
|
|
||||||
const apiConfig: AxiosRequestConfig = {
|
const apiConfig: AxiosRequestConfig = {
|
||||||
baseURL: `${constants.BACKEND_URL}/api/`,
|
baseURL: `${constants.BACKEND_URL}/api/`,
|
||||||
|
|||||||
@ -13,6 +13,7 @@ import {
|
|||||||
Flex,
|
Flex,
|
||||||
Divider,
|
Divider,
|
||||||
} from '@chakra-ui/react';
|
} from '@chakra-ui/react';
|
||||||
|
import * as constants from '@educt/constants';
|
||||||
import { Controller, UseFormReturn } from 'react-hook-form';
|
import { Controller, UseFormReturn } from 'react-hook-form';
|
||||||
import VideoUploader from '@educt/components/VideoUploader';
|
import VideoUploader from '@educt/components/VideoUploader';
|
||||||
import FilesUploader from '@educt/components/FilesUploader';
|
import FilesUploader from '@educt/components/FilesUploader';
|
||||||
@ -80,7 +81,11 @@ const LessonForm: React.FC<LessonFormPropsType> = ({
|
|||||||
control={control}
|
control={control}
|
||||||
name='video'
|
name='video'
|
||||||
render={({ field: { onChange, value: file } }) => (
|
render={({ field: { onChange, value: file } }) => (
|
||||||
<VideoUploader onChange={file => onChange(file)} file={file} preloadedVideoUrl={preloadedVideo?.url} />
|
<VideoUploader
|
||||||
|
onChange={file => onChange(file)}
|
||||||
|
file={file}
|
||||||
|
preloadedVideoUrl={constants.BACKEND_URL + preloadedVideo?.url}
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
<Text as='small' color='red.500'>
|
<Text as='small' color='red.500'>
|
||||||
|
|||||||
2
src/constants.ts
Normal file
2
src/constants.ts
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
export const BACKEND_URL = import.meta.env.VITE_API_URL || 'http://localhost:3333';
|
||||||
|
export const WS_URL = 'ws://localhost:3333';
|
||||||
9
src/env.d.ts
vendored
Normal file
9
src/env.d.ts
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
/// <reference types="vite/client" />
|
||||||
|
|
||||||
|
interface ImportMetaEnv {
|
||||||
|
readonly VITE_API_URL?: string | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ImportMeta {
|
||||||
|
readonly env: ImportMetaEnv;
|
||||||
|
}
|
||||||
@ -1,6 +1,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { observer } from 'mobx-react';
|
import { observer } from 'mobx-react';
|
||||||
import * as helpres from '@educt/helpers';
|
import * as helpres from '@educt/helpers';
|
||||||
|
import * as constants from '@educt/constants';
|
||||||
import { Redirect } from 'react-router-dom';
|
import { Redirect } from 'react-router-dom';
|
||||||
import { Flex, Box, Text, Heading, Button, Grid, GridItem, Divider, AvatarGroup, Avatar } from '@chakra-ui/react';
|
import { Flex, Box, Text, Heading, Button, Grid, GridItem, Divider, AvatarGroup, Avatar } from '@chakra-ui/react';
|
||||||
import { MdPlayCircleOutline } from 'react-icons/md';
|
import { MdPlayCircleOutline } from 'react-icons/md';
|
||||||
@ -83,7 +84,10 @@ const CoursePage: React.FC<IPageProps> = () => {
|
|||||||
</Button>
|
</Button>
|
||||||
</Box>
|
</Box>
|
||||||
</Flex>
|
</Flex>
|
||||||
<CourseBackgroundImage bg={course.color?.hex} src={course.image?.url} />
|
<CourseBackgroundImage
|
||||||
|
bg={course.color?.hex}
|
||||||
|
src={course.image ? `${constants.BACKEND_URL + course.image.url}` : undefined}
|
||||||
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
<Box mt='4'>
|
<Box mt='4'>
|
||||||
<Tabs>
|
<Tabs>
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import { Menu, MenuButton, MenuItem, MenuList } from '@chakra-ui/menu';
|
|||||||
import { MdMoreHoriz, MdGroup, MdThumbUp, MdVideoLibrary } from 'react-icons/md';
|
import { MdMoreHoriz, MdGroup, MdThumbUp, MdVideoLibrary } from 'react-icons/md';
|
||||||
import { AiOutlineEye, AiOutlineEyeInvisible } from 'react-icons/ai';
|
import { AiOutlineEye, AiOutlineEyeInvisible } from 'react-icons/ai';
|
||||||
import { DeleteIcon, EditIcon } from '@chakra-ui/icons';
|
import { DeleteIcon, EditIcon } from '@chakra-ui/icons';
|
||||||
|
import * as constants from '@educt/constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Types
|
* Types
|
||||||
@ -128,7 +129,7 @@ const CourseItem: React.FC<CourseItemPropsType> = ({ course, onDelete, onSetStat
|
|||||||
w='100%'
|
w='100%'
|
||||||
borderTopLeftRadius='lg'
|
borderTopLeftRadius='lg'
|
||||||
borderTopRightRadius='lg'
|
borderTopRightRadius='lg'
|
||||||
src={course.image.url}
|
src={course.image ? `${constants.BACKEND_URL + course.image.url}` : undefined}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
|
import * as constants from '@educt/constants';
|
||||||
import * as helpres from '@educt/helpers';
|
import * as helpres from '@educt/helpers';
|
||||||
import { Link as ReactRouterLink, Redirect } from 'react-router-dom';
|
import { Link as ReactRouterLink, Redirect } from 'react-router-dom';
|
||||||
import { Helmet } from 'react-helmet';
|
import { Helmet } from 'react-helmet';
|
||||||
@ -153,7 +154,7 @@ const LessonPage: React.FC<IPageProps> = () => {
|
|||||||
<GridItem>
|
<GridItem>
|
||||||
<Box>
|
<Box>
|
||||||
{lesson.video ? (
|
{lesson.video ? (
|
||||||
<ReactPlayer width={'100%'} height={'100%'} controls url={lesson.video?.url} />
|
<ReactPlayer width={'100%'} height={'100%'} controls url={constants.BACKEND_URL + lesson.video.url} />
|
||||||
) : (
|
) : (
|
||||||
<Flex h='500px' justifyContent={'center'} alignItems={'center'}>
|
<Flex h='500px' justifyContent={'center'} alignItems={'center'}>
|
||||||
<Text color='gray.500' userSelect={'none'}>
|
<Text color='gray.500' userSelect={'none'}>
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import React, { useState, ReactNode } from 'react';
|
import React, { useState, ReactNode } from 'react';
|
||||||
import * as constants from '../../constants';
|
import * as constants from '@educt/constants';
|
||||||
import {
|
import {
|
||||||
ChangeEmailPageContext,
|
ChangeEmailPageContext,
|
||||||
CoursesPageContext,
|
CoursesPageContext,
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
import { defineConfig } from 'vite';
|
import { defineConfig } from 'vite';
|
||||||
import * as constants from './constants';
|
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import react from '@vitejs/plugin-react';
|
import react from '@vitejs/plugin-react';
|
||||||
import { visualizer } from 'rollup-plugin-visualizer';
|
import { visualizer } from 'rollup-plugin-visualizer';
|
||||||
@ -21,20 +20,6 @@ export default defineConfig({
|
|||||||
plugins: [react()],
|
plugins: [react()],
|
||||||
server: {
|
server: {
|
||||||
port: 5000,
|
port: 5000,
|
||||||
proxy: {
|
|
||||||
'/api': {
|
|
||||||
target: constants.BACKEND_URL,
|
|
||||||
changeOrigin: true,
|
|
||||||
},
|
|
||||||
'/uploads': {
|
|
||||||
target: constants.BACKEND_URL,
|
|
||||||
changeOrigin: true,
|
|
||||||
},
|
|
||||||
'/video': {
|
|
||||||
target: constants.BACKEND_URL,
|
|
||||||
changeOrigin: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
resolve: {
|
resolve: {
|
||||||
alias: [{ find: '@educt', replacement: path.resolve(__dirname, 'src') }],
|
alias: [{ find: '@educt', replacement: path.resolve(__dirname, 'src') }],
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user