feat: update Dockerfile and nginx configuration for improved API routing; modify events API response structure
This commit is contained in:
@@ -17,14 +17,8 @@ RUN npm run build
|
|||||||
FROM nginx:alpine
|
FROM nginx:alpine
|
||||||
|
|
||||||
COPY --from=build /app/dist /usr/share/nginx/html
|
COPY --from=build /app/dist /usr/share/nginx/html
|
||||||
COPY nginx.conf /etc/nginx/nginx.conf.template
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
|
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|
||||||
# API_URL is the backend's public base URL used by nginx proxy_pass.
|
CMD ["nginx", "-g", "daemon off;"]
|
||||||
# Set this at runtime in Coolify, e.g. API_URL=https://api.crowmate.fr
|
|
||||||
ENV API_URL=http://localhost:3000
|
|
||||||
|
|
||||||
# Substitute ${API_URL} in the nginx template at container start, then launch nginx.
|
|
||||||
# The quoted variable list prevents envsubst from replacing nginx variables like $host.
|
|
||||||
CMD ["/bin/sh", "-c", "envsubst '${API_URL}' < /etc/nginx/nginx.conf.template > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'"]
|
|
||||||
|
|||||||
@@ -3,8 +3,12 @@ server {
|
|||||||
root /usr/share/nginx/html;
|
root /usr/share/nginx/html;
|
||||||
index index.html;
|
index index.html;
|
||||||
|
|
||||||
|
# Use Docker's embedded DNS resolver; defer resolution to request time
|
||||||
|
resolver 127.0.0.11 valid=30s;
|
||||||
|
|
||||||
location /api/ {
|
location /api/ {
|
||||||
proxy_pass ${API_URL}/api/;
|
set $api_upstream http://api:3000;
|
||||||
|
proxy_pass $api_upstream;
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
|||||||
@@ -257,7 +257,7 @@ export default function EventsPage() {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
eventsApi.getEvents(true)
|
eventsApi.getEvents(true)
|
||||||
.then((res) => setEvents(res.data))
|
.then((res) => setEvents(res.events))
|
||||||
.catch(() => setEvents([]))
|
.catch(() => setEvents([]))
|
||||||
.finally(() => setLoading(false));
|
.finally(() => setLoading(false));
|
||||||
}, []);
|
}, []);
|
||||||
|
|||||||
@@ -173,7 +173,7 @@ export const eventsApi = {
|
|||||||
getEvents: (publicOnly = true) => {
|
getEvents: (publicOnly = true) => {
|
||||||
const q = new URLSearchParams({ limit: '50' });
|
const q = new URLSearchParams({ limit: '50' });
|
||||||
if (publicOnly) q.set('public', 'true');
|
if (publicOnly) q.set('public', 'true');
|
||||||
return apiFetch<{ data: EventPost[]; total: number; page: number; pages: number }>(
|
return apiFetch<{ events: EventPost[]; total: number; page: number; pages: number }>(
|
||||||
`/events?${q}`
|
`/events?${q}`
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user