Skip to content

Commit 8f13689

Browse files
committed
Fix allowedDomains array initialization
1 parent 59bd90c commit 8f13689

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const allowedDomains = process.env.ALLOWED_REMOTE_DOMAINS.split(",") || "*";
1+
const allowedDomains = process.env.ALLOWED_REMOTE_DOMAINS.split(",") || ["*"];
22
const imgproxyUrl = process.env.IMGPROXY_URL || "http://imgproxy:8080";
33

44
Bun.serve({
@@ -17,8 +17,8 @@ async function resize(url) {
1717
const preset = "pr:sharp"
1818
const src = url.pathname.split("/").slice(2).join("/");
1919
const origin = new URL(src).hostname;
20-
if (allowedDomains !== "*" && !allowedDomains.includes(origin)) {
21-
return new Response("Domain not allowed. More details here: https://github.com/coollabsio/next-image-transformation", { status: 403 });
20+
if (allowedDomains.includes("*") && !allowedDomains.includes(origin)) {
21+
return new Response(`Domain (${origin}) not allowed. More details here: https://github.com/coollabsio/next-image-transformation`, { status: 403 });
2222
}
2323
const width = url.searchParams.get("width") || 0;
2424
const height = url.searchParams.get("height") || 0;

0 commit comments

Comments
 (0)