Skip to content

Commit

Permalink
Add support for extension-less html files
Browse files Browse the repository at this point in the history
  • Loading branch information
n4bb12 committed Dec 24, 2020
1 parent 01f74aa commit 57aa158
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/fastify-static.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ import { Config } from "./types"
// https://github.com/fastify/fastify-static#fastify-static
//
export function registerServeStatic(server: FastifyInstance, config: Config) {
server.setNotFoundHandler((req, res) => {
server.setNotFoundHandler(async (req, res) => {
res.sendFile("index.html", config.staticDir)
})
server.register(fastifyStatic, {
root: path.resolve(config.staticDir),
extensions: ["html", "htm"],
})
}

0 comments on commit 57aa158

Please sign in to comment.