Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #328

Merged
merged 5 commits into from
Jan 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,9 @@ WORKDIR /app
COPY package*.json .
RUN npm install
COPY . .
ARG VITE_BASE_URL
ENV VITE_BASE_URL=$VITE_BASE_URL
ARG VITE_API_URL
ENV VITE_API_URL=$VITE_API_URL
RUN npm run build
CMD cp -r build result_build
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,17 @@ npm ci
npm run dev
```

### Env

Адреса приложения и API необходимо указать в файле **.env** в корне проекта.

#### Пример .env файла

```text
VITE_BASE_URL=http://localhost:3000
VITE_API_URL=http://localhost:3000/api
```

Подробная информация по работе с проектом в файле `CONTRIBUTE.MD`

## Ссылки
Expand Down
1 change: 1 addition & 0 deletions env.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
interface ImportMetaEnv {
VITE_API_URL: string;
VITE_BASE_URL: string;
NODE_ENV: string;
VITE_JWT_SECRET: string;
VITE_PORT: string;
Expand Down
2 changes: 1 addition & 1 deletion src/components/product-card/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const ProductCard: React.FC<ProductCardProps> = ({
<img
className={styles.image}
src={
cardImage !== undefined && cardImage !== null
cardImage
? cardImage.startsWith('/')
? `${BASE_URL}${cardImage}`
: cardImage
Expand Down
3 changes: 2 additions & 1 deletion src/components/shopping-item/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import styles from './shopping-item.module.scss';
import { Link } from 'react-router-dom';
import { useCart } from '@hooks/use-cart-context.ts';
import { translateMeasureUnit } from '@utils/utils';
import { BASE_URL } from '@data/constants';

type ShoppingItemProps = {
product: {
Expand Down Expand Up @@ -44,7 +45,7 @@ const ShoppingItem: React.FC<ShoppingItemProps> = (props) => {
<Link to={`/catalog/${product.category}/${product.id}`}>
<img
className={styles.item__image}
src={`https://goodfood.acceleratorpracticum.ru/media/${product.photo}`}
src={`${BASE_URL}/media/${product.photo}`}
alt={product.name}
/>
</Link>
Expand Down
4 changes: 2 additions & 2 deletions src/data/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const BACKEND_URL = 'https://goodfood.acceleratorpracticum.ru/api';
export const BASE_URL = 'https://goodfood.acceleratorpracticum.ru';
export const BACKEND_URL = import.meta.env.VITE_API_URL;
export const BASE_URL = import.meta.env.VITE_BASE_URL;

export const URLS = {
SIGNUP: '/signup',
Expand Down
4 changes: 4 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,8 @@ export default defineConfig({
},
},
plugins: [react(), svgr()],
define: {
VITE_BASE_URL: process.env.VITE_BASE_URL,
VITE_API_URL: process.env.VITE_API_URL,
},
});
Loading