mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 12:37:20 +00:00
updated cf image optimization plugin
This commit is contained in:
@@ -4,14 +4,12 @@ export type CloudflareImageOptimizationOptions = {
|
||||
accessUrl?: string;
|
||||
resolvePath?: string;
|
||||
autoFormat?: boolean;
|
||||
devBypass?: string;
|
||||
};
|
||||
|
||||
export function cloudflareImageOptimization({
|
||||
accessUrl = "/_plugin/image/optimize",
|
||||
resolvePath = "/api/media/file",
|
||||
autoFormat = true,
|
||||
devBypass,
|
||||
}: CloudflareImageOptimizationOptions = {}): AppPlugin {
|
||||
const disallowedAccessUrls = ["/api", "/admin", "/_optimize"];
|
||||
if (disallowedAccessUrls.includes(accessUrl) || accessUrl.length < 2) {
|
||||
@@ -25,10 +23,6 @@ export function cloudflareImageOptimization({
|
||||
const request = c.req.raw;
|
||||
const url = new URL(request.url);
|
||||
|
||||
if (devBypass) {
|
||||
return c.redirect(devBypass + url.pathname + url.search, 302);
|
||||
}
|
||||
|
||||
const storage = app.module.media?.storage;
|
||||
if (!storage) {
|
||||
throw new Error("No media storage configured");
|
||||
|
||||
Reference in New Issue
Block a user