correct config

This commit is contained in:
ordinarthur 2026-03-12 20:20:56 +01:00
parent 9175004893
commit 090a61d452
3 changed files with 22 additions and 29 deletions

View File

@ -36,6 +36,11 @@ services:
- coolify - coolify
- default - default
restart: unless-stopped restart: unless-stopped
labels:
- traefik.enable=true
- traefik.http.routers.rebours.rule=Host(`rebours.studio`)
- traefik.http.routers.rebours.entrypoints=http
- traefik.http.services.rebours.loadbalancer.server.port=80
volumes: volumes:
dist-data: dist-data:

View File

@ -14,6 +14,23 @@ server {
proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Proto $scheme;
} }
# ── SEO proxy Fastify (dynamique depuis DB) ─────────────────────────────
location = /robots.txt {
proxy_pass http://server:3001;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location = /sitemap.xml {
proxy_pass http://server:3001;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
# ── Admin proxy Fastify (AdminJS) ────────────────────────────────────── # ── Admin proxy Fastify (AdminJS) ──────────────────────────────────────
location /admin { location /admin {
proxy_pass http://server:3001; proxy_pass http://server:3001;

View File

@ -1,17 +1,12 @@
import Fastify from 'fastify' import Fastify from 'fastify'
import cors from '@fastify/cors' import cors from '@fastify/cors'
import fastifyStatic from '@fastify/static'
import Stripe from 'stripe' import Stripe from 'stripe'
import dotenv from 'dotenv' import dotenv from 'dotenv'
import { fileURLToPath } from 'url'
import { dirname, join } from 'path'
import { setupAdmin } from './admin.mjs' import { setupAdmin } from './admin.mjs'
import { prisma } from './src/lib/db.mjs' import { prisma } from './src/lib/db.mjs'
dotenv.config() dotenv.config()
const __dirname = dirname(fileURLToPath(import.meta.url))
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY ?? '') const stripe = new Stripe(process.env.STRIPE_SECRET_KEY ?? '')
const DOMAIN = process.env.DOMAIN ?? 'http://localhost:4321' const DOMAIN = process.env.DOMAIN ?? 'http://localhost:4321'
@ -153,30 +148,6 @@ app.get('/api/session/:id', async (request) => {
} }
}) })
// ── Static files (prod only — en dev, Vite/Astro s'en charge) ───────────
if (process.env.NODE_ENV === 'production') {
await app.register(fastifyStatic, {
root: join(__dirname, 'dist'),
prefix: '/',
decorateReply: false,
setHeaders(res, path) {
if (path.endsWith('.html')) {
res.setHeader('Cache-Control', 'no-store')
} else {
res.setHeader('Cache-Control', 'public, max-age=31536000, immutable')
}
},
})
// SPA fallback — sert index.html pour les routes Astro
app.setNotFoundHandler(async (request, reply) => {
if (request.url.startsWith('/api') || request.url.startsWith('/admin')) {
return reply.code(404).send({ error: 'Not found' })
}
return reply.sendFile('index.html')
})
}
// ── Start ─────────────────────────────────────────────────────────────────── // ── Start ───────────────────────────────────────────────────────────────────
try { try {
await app.listen({ port: process.env.PORT ?? 3000, host: '0.0.0.0' }) await app.listen({ port: process.env.PORT ?? 3000, host: '0.0.0.0' })