Skip to content

Commit 159e36b

Browse files
committed
Update imgproxy URL based on NODE_ENV
1 parent 73e70c7 commit 159e36b

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

index.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
const version = "0.0.3"
22

33
const allowedDomains = process?.env?.ALLOWED_REMOTE_DOMAINS?.split(",") || ["*"];
4-
const imgproxyUrl = process?.env?.IMGPROXY_URL || "http://imgproxy:8080";
4+
let imgproxyUrl = process?.env?.IMGPROXY_URL || "http://imgproxy:8080";
5+
if (process.env.NODE_ENV === "development") {
6+
imgproxyUrl = "http://localhost:8888"
7+
}
58

69
Bun.serve({
710
port: 3000,
@@ -35,9 +38,9 @@ async function resize(url) {
3538
const quality = url.searchParams.get("quality") || 75;
3639
try {
3740
const url = `${imgproxyUrl}/${preset}/resize:fill:${width}:${height}/q:${quality}/plain/${src}`
38-
const image = await fetch(url , {
41+
const image = await fetch(url, {
3942
headers: {
40-
"Accept": "image/avif,image/webp,image/*,",
43+
"Accept": "image/avif,image/webp,image/apng,*/*",
4144
}
4245
})
4346
const headers = new Headers(image.headers);

0 commit comments

Comments
 (0)