import { existsSync } from 'node:fs' import app from '@adonisjs/core/services/app' import type { HttpContext } from '@adonisjs/core/http' /** * Serves the Angular application for every URL that is neither a file * of "public/" nor an API route (/containers, /projects/…). */ export default class SpaController { async index({ request, response }: HttpContext) { if (request.url().startsWith('/api/')) { return response.notFound({ message: 'Route inconnue.' }) } const index = app.publicPath('index.html') if (!existsSync(index)) { return response.notFound( 'Interface non compilée : lance "npm run build" dans web/ (ou "npm start" pour le développement).' ) } response.header('Cache-Control', 'no-cache') return response.download(index) } }