Files
integration/website/server.mjs
Emmanuel Pelletier 0593bbad15 website: precompress static files instead of relying on fastify compress
- no need to generate the compressed files at runtime
- this prevents an issue with fastify compressing pagefind files
2024-05-13 14:36:23 +02:00

20 lines
408 B
JavaScript

import { join } from "path"
import Fastify from "fastify"
import fsfStatic from "@fastify/static"
const fastify = Fastify({
logger: true,
})
fastify.register(fsfStatic, {
root: join(import.meta.dirname, process.env.STATIC_DIR || "dist"),
preCompressed: true,
})
try {
fastify.listen({ port: process.env.PORT || 3000, host: "0.0.0.0" })
} catch (err) {
fastify.log.error(err)
process.exit(1)
}