Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
syuilo committed Sep 22, 2024
1 parent db3932e commit 0c57ab8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/backend/src/misc/fastify-hook-handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type { onRequestHookHandler } from 'fastify';
export const handleRequestRedirectToOmitSearch: onRequestHookHandler = (request, reply, done) => {
const index = request.url.indexOf('?');
if (~index) {
reply.redirect(301, request.url.slice(0, index));
reply.redirect(request.url.slice(0, index), 301);
}
done();
};
10 changes: 5 additions & 5 deletions packages/backend/src/server/FileServerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export class FileServerService {
.catch(err => this.errorHandler(request, reply, err));
});
fastify.get<{ Params: { key: string; } }>('/files/:key/*', async (request, reply) => {
return await reply.redirect(301, `${this.config.url}/files/${request.params.key}`);
return await reply.redirect(`${this.config.url}/files/${request.params.key}`, 301);
});
done();
});
Expand Down Expand Up @@ -147,12 +147,12 @@ export class FileServerService {
url.searchParams.set('static', '1');

file.cleanup();
return await reply.redirect(301, url.toString());
return await reply.redirect(url.toString(), 301);
} else if (file.mime.startsWith('video/')) {
const externalThumbnail = this.videoProcessingService.getExternalVideoThumbnailUrl(file.url);
if (externalThumbnail) {
file.cleanup();
return await reply.redirect(301, externalThumbnail);
return await reply.redirect(externalThumbnail, 301);
}

image = await this.videoProcessingService.generateVideoThumbnail(file.path);
Expand All @@ -167,7 +167,7 @@ export class FileServerService {
url.searchParams.set('url', file.url);

file.cleanup();
return await reply.redirect(301, url.toString());
return await reply.redirect(url.toString(), 301);
}
}

Expand Down Expand Up @@ -314,8 +314,8 @@ export class FileServerService {
}

return await reply.redirect(
301,
url.toString(),
301,
);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/server/ServerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ export class ServerService implements OnApplicationShutdown {
}

return await reply.redirect(
301,
url.toString(),
301,
);
});

Expand Down

0 comments on commit 0c57ab8

Please sign in to comment.