feat: setup project for docker deploy

This commit is contained in:
2025-07-23 22:00:35 +00:00
parent 98369ef531
commit 715bc90340
12 changed files with 139 additions and 10 deletions

View File

@@ -1,4 +1,3 @@
# Frontend environment variables #
REACT_APP_API_BASE_URL=http://localhost:8000
REACT_APP_BASE_URL=http://localhost:8000

8
frontend/Dockerfile Normal file
View File

@@ -0,0 +1,8 @@
FROM node:20-alpine AS builder
WORKDIR /app
COPY . .
RUN npm install && npm run build
FROM nginx:alpine
COPY --from=builder /app/build /usr/share/nginx/html

View File

@@ -5,7 +5,7 @@ const baseUrl = process.env.REACT_APP_API_BASE_URL
export async function shortenUrlApi(
payload: ShortenUrlRequest
): Promise<ShortenUrlResponse> {
const response = await fetch(`${baseUrl}/`, {
const response = await fetch(`${baseUrl}/api/shorten`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload),

View File

@@ -6,7 +6,7 @@ import { UrlState } from './types';
export const shortenUrl = createAsyncThunk(
'url/shortenUrl',
async (url: string) => {
const baseUrl = process.env.REACT_APP_BASE_URL
const baseUrl = process.env.REACT_APP_API_BASE_URL
const data = await shortenUrlApi({ url });
return `${baseUrl}/${data.shortcode}`;
}