summaryrefslogtreecommitdiff
path: root/src/server/proxy
diff options
context:
space:
mode:
authorMeiMei <30769358+mei23@users.noreply.github.com>2021-10-16 17:16:24 +0900
committerGitHub <noreply@github.com>2021-10-16 17:16:24 +0900
commit482081c41b45ab3798e73c4d11e8a7c1c1f5e8c9 (patch)
treefed02348c2fce534f8101370853eb83fbf3aa899 /src/server/proxy
parentテスト用コンテナの調整 (#7838) (diff)
downloadsharkey-482081c41b45ab3798e73c4d11e8a7c1c1f5e8c9.tar.gz
sharkey-482081c41b45ab3798e73c4d11e8a7c1c1f5e8c9.tar.bz2
sharkey-482081c41b45ab3798e73c4d11e8a7c1c1f5e8c9.zip
Refactor request (#7814)
* status code * Test ap-request.ts https://github.com/mei23/crytest/blob/4397fc5e70536e4175fe56e974ca83b8047bef3a/test/ap-request.ts * tune
Diffstat (limited to 'src/server/proxy')
-rw-r--r--src/server/proxy/proxy-media.ts5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/server/proxy/proxy-media.ts b/src/server/proxy/proxy-media.ts
index 3bd65dfe67..9e13c0877f 100644
--- a/src/server/proxy/proxy-media.ts
+++ b/src/server/proxy/proxy-media.ts
@@ -5,6 +5,7 @@ import { IImage, convertToPng, convertToJpeg } from '@/services/drive/image-proc
import { createTemp } from '@/misc/create-temp';
import { downloadUrl } from '@/misc/download-url';
import { detectType } from '@/misc/get-file-info';
+import { StatusError } from '@/misc/fetch';
export async function proxyMedia(ctx: Koa.Context) {
const url = 'url' in ctx.query ? ctx.query.url : 'https://' + ctx.params.url;
@@ -37,9 +38,9 @@ export async function proxyMedia(ctx: Koa.Context) {
ctx.set('Cache-Control', 'max-age=31536000, immutable');
ctx.body = image.data;
} catch (e) {
- serverLogger.error(e);
+ serverLogger.error(`${e}`);
- if (typeof e.statusCode === 'number' && e.statusCode >= 400 && e.statusCode < 500) {
+ if (e instanceof StatusError && e.isClientError) {
ctx.status = e.statusCode;
} else {
ctx.status = 500;