feat: setup project for docker deploy
This commit is contained in:
@@ -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
8
frontend/Dockerfile
Normal 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
|
||||
@@ -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),
|
||||
|
||||
@@ -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}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user