fix hook targets

This commit is contained in:
Hazelnoot 2025-05-06 18:46:08 -04:00
parent 89cab66898
commit cbe88122b9

View file

@ -28,7 +28,7 @@ export class ServerUtilityService {
// Default behavior saves files to memory - we don't want that! // Default behavior saves files to memory - we don't want that!
// Store to temporary file instead, and copy the body fields while we're at it. // Store to temporary file instead, and copy the body fields while we're at it.
fastify.addHook<{ Body?: Record<string, string | string[] | undefined> }>('onRequest', async request => { fastify.addHook<{ Body?: Record<string, string | string[] | undefined> }>('preValidation', async request => {
if (request.isMultipart()) { if (request.isMultipart()) {
// We can't use saveRequestFiles() because it erases all the data fields. // We can't use saveRequestFiles() because it erases all the data fields.
// Instead, recreate it manually. // Instead, recreate it manually.
@ -94,7 +94,7 @@ export class ServerUtilityService {
} }
public addCORS(fastify: FastifyInstance) { public addCORS(fastify: FastifyInstance) {
fastify.addHook('onRequest', (_, reply, done) => { fastify.addHook('preHandler', (_, reply, done) => {
// Allow web-based clients to connect from other origins. // Allow web-based clients to connect from other origins.
reply.header('Access-Control-Allow-Origin', '*'); reply.header('Access-Control-Allow-Origin', '*');