mirror of
https://github.com/lifegpc/eh-downloader.git
synced 2026-06-06 05:38:44 +08:00
Add X-Forwarded-Proto support
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { Handlers } from "$fresh/server.ts";
|
||||
import { get_task_manager } from "../../../server.ts";
|
||||
import { parse_bool } from "../../../server/parse_form.ts";
|
||||
import { get_host } from "../../../server/utils.ts";
|
||||
|
||||
export const handler: Handlers = {
|
||||
async GET(req, _ctx) {
|
||||
@@ -12,6 +13,6 @@ export const handler: Handlers = {
|
||||
const f = m.db.get_random_file(is_nsfw, is_ad);
|
||||
if (!f) return new Response("File not found.", { status: 404 });
|
||||
const t = thumb ? "thumbnail" : "file";
|
||||
return Response.redirect(`${u.origin}/api/${t}/${f.id}`);
|
||||
return Response.redirect(`${get_host(req)}/api/${t}/${f.id}`);
|
||||
},
|
||||
};
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
get_file_response,
|
||||
GetFileResponseOptions,
|
||||
} from "../../../server/get_file_response.ts";
|
||||
import { get_host } from "../../../server/utils.ts";
|
||||
|
||||
export const handler: Handlers = {
|
||||
async GET(req, ctx) {
|
||||
@@ -52,7 +53,7 @@ export const handler: Handlers = {
|
||||
}
|
||||
if (!force) {
|
||||
if (cfg.width > f.width || cfg.height > f.height) {
|
||||
return Response.redirect(`${u.origin}/api/file/${f.id}`);
|
||||
return Response.redirect(`${get_host(req)}/api/file/${f.id}`);
|
||||
}
|
||||
}
|
||||
const output = generate_filename(b, f, cfg);
|
||||
|
||||
Reference in New Issue
Block a user