perf: omit search for immutable static requests (#13265)

* perf: omit search for immutable static requests

* perf: also applies to /files

* fix: exclude /proxy

* /files/:key/*を301 redirectに

---------

Co-authored-by: tamaina <tamaina@hotmail.co.jp>
This commit is contained in:
Acid Chicken (硫酸鶏)
2024-02-13 01:43:06 +00:00
committed by GitHub
parent 50817df59c
commit 309a943528
3 changed files with 47 additions and 23 deletions

View File

@@ -0,0 +1,9 @@
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));
}
done();
};