add prefix on frontend
This commit is contained in:
parent
c6e9e6cc77
commit
38b6ddcd5d
8 changed files with 19 additions and 30 deletions
|
|
@ -29,7 +29,7 @@ Backend (`cd backend`):
|
|||
- Build: `./mvnw package`
|
||||
|
||||
Frontend (`cd frontend`):
|
||||
- Dev: `npm run dev` (port 5173, proxies `/api/*` → `http://localhost:8080`)
|
||||
- Dev: `npm run dev` (port 5173, calls backend directly at `http://localhost:8080` via `VITE_API_URL`)
|
||||
- Build: `npm run build` (runs `tsc -b` then `vite build`)
|
||||
- Lint: `npm run lint`
|
||||
|
||||
|
|
@ -90,7 +90,7 @@ The authenticated email comes from `securityIdentity.getPrincipal().getName()` a
|
|||
|
||||
- **React 19**, **Tailwind v4** (`@tailwindcss/vite`, no Tailwind config file required), **react-router-dom v7**.
|
||||
- Folder layout: `pages/`, `components/`, `services/`, `contexts/`, `types/`, `lib/`.
|
||||
- HTTP through `apiFetch` in `src/lib/api.ts` — it auto-injects the JWT from `localStorage.user.jwt` and prefixes `VITE_API_URL` (defaults to `/api`, proxied by Vite to the backend).
|
||||
- HTTP through `apiFetch` in `src/lib/api.ts` — it auto-injects the JWT from `localStorage.user.jwt` and prefixes `VITE_API_URL` (defaults to `http://localhost:8080` em dev; configurar para a URL real do backend em prod).
|
||||
- Each backend feature gets a service in `services/<feature>Service.ts` exporting an object of methods.
|
||||
- Class merging uses `cn(...inputs)` from `src/lib/utils.ts` (clsx + tailwind-merge).
|
||||
- Icons: `lucide-react`. Animations: `framer-motion`. DnD: `@hello-pangea/dnd`.
|
||||
|
|
|
|||
|
|
@ -54,11 +54,13 @@ services:
|
|||
- "traefik.enable=true"
|
||||
|
||||
- "traefik.http.routers.frontend.rule=PathPrefix(`/frontend`)"
|
||||
|
||||
- "traefik.http.routers.frontend.entrypoints=websecure"
|
||||
- "traefik.http.routers.frontend.tls.certresolver=letsencrypt"
|
||||
- "traefik.http.routers.frontend.middlewares=frontend-strip"
|
||||
|
||||
- "traefik.http.services.frontend.loadbalancer.server.port=3000"
|
||||
- "traefik.http.middlewares.frontend-strip.stripprefix.prefixes=/frontend"
|
||||
|
||||
- "traefik.http.services.frontend.loadbalancer.server.port=80"
|
||||
|
||||
volumes:
|
||||
postgres_data:
|
||||
|
|
|
|||
6
frontend/Caddyfile
Normal file
6
frontend/Caddyfile
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
:80 {
|
||||
root * /srv
|
||||
encode gzip
|
||||
try_files {path} /index.html
|
||||
file_server
|
||||
}
|
||||
|
|
@ -7,14 +7,14 @@ RUN npm ci
|
|||
|
||||
COPY . .
|
||||
|
||||
ARG VITE_API_URL=/api
|
||||
ARG VITE_API_URL
|
||||
ENV VITE_API_URL=$VITE_API_URL
|
||||
|
||||
RUN npm run build
|
||||
|
||||
FROM nginx:1.29-alpine
|
||||
FROM caddy:2-alpine
|
||||
|
||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||
COPY --from=build /app/dist /usr/share/nginx/html
|
||||
COPY Caddyfile /etc/caddy/Caddyfile
|
||||
COPY --from=build /app/dist /srv
|
||||
|
||||
EXPOSE 80
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
server {
|
||||
listen 80;
|
||||
server_name _;
|
||||
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
const API_BASE_URL = (import.meta.env.VITE_API_URL as string | undefined) ?? '/api'
|
||||
const API_BASE_URL = (import.meta.env.VITE_API_URL as string | undefined) ?? 'http://localhost:8080'
|
||||
|
||||
function buildUrl(path: string) {
|
||||
return `${API_BASE_URL}${path}`
|
||||
|
|
|
|||
|
|
@ -91,4 +91,4 @@ export const router = createBrowserRouter([
|
|||
},
|
||||
],
|
||||
},
|
||||
]);
|
||||
], { basename: '/frontend' });
|
||||
|
|
|
|||
|
|
@ -4,17 +4,9 @@ import { defineConfig } from 'vite'
|
|||
import pkg from './package.json'
|
||||
|
||||
export default defineConfig({
|
||||
base: '/frontend/',
|
||||
define: {
|
||||
'import.meta.env.VITE_APP_VERSION': JSON.stringify(pkg.version),
|
||||
},
|
||||
plugins: [react(), tailwindcss()],
|
||||
server: {
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: process.env.VITE_API_PROXY_TARGET ?? 'http://localhost:8080',
|
||||
changeOrigin: true,
|
||||
rewrite: (path) => path.replace(/^\/api/, ''),
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in a new issue