Skip to content

Dynamic file type support #21

@5ouma

Description

@5ouma

✏️ Describe the feature

Currently, it responds to the request with contents as text/plain so they must be code files. However, some people might specify non-text files such as images or videos, so it should detect the file type and change the response MIME type.

✔︎ Confirm these checks

🗒️ Additional Information

reproxy/src/router.ts

Lines 4 to 14 in 1bb2d1f

export const router = new Router();
router
.get("/", async <R extends string>(ctx: RouterContext<R>) => {
ctx.response.type = "text/plain";
if (!redirect(ctx, ctx.request.userAgent)) await getContent(ctx);
})
.get("/:ref", async <R extends string>(ctx: RouterContext<R>) => {
const ref: string | undefined = ctx.params.ref;
ctx.response.type = "text/plain";
if (!redirect(ctx, ctx.request.userAgent, ref)) await getContent(ctx, ref);
});

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions