txtdot/src/errors/handler.ts

15 lines
330 B
TypeScript
Raw Normal View History

2023-08-16 13:20:24 +03:00
import { FastifyReply, FastifyRequest } from "fastify";
import { NotHtmlMimetypeError } from "./main";
export default function errorHandler(
error: Error,
_: FastifyRequest,
reply: FastifyReply
) {
if (error instanceof NotHtmlMimetypeError) {
return reply.redirect(301, error.url);
} else {
return error;
}
}