Skip to content

Commit

Permalink
Add patch to proxy i.imgur.com requests
Browse files Browse the repository at this point in the history
  • Loading branch information
DonovanDMC committed Jun 3, 2024
1 parent 02c0b71 commit 8071cb6
Show file tree
Hide file tree
Showing 6 changed files with 292 additions and 24 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ COPY package.json package-lock.json ./
RUN npm install
COPY . .
RUN npm run build
RUN npx patch-package
RUN npm prune --prod
CMD ["node", "--no-warnings", "--no-deprecation", "--experimental-specifier-resolution=node", "dist/src/index.js"]
252 changes: 252 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
"markdown-it": "^14.1.0",
"morgan": "^1.10.0",
"oceanic.js": "^1.10.4",
"patch-package": "^8.0.0",
"pg": "^8.11.5",
"short-uuid": "^5.2.0",
"tsafe": "^1.6.6",
Expand Down
18 changes: 18 additions & 0 deletions patches/@napi-rs+canvas+0.1.52.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
diff --git a/node_modules/@napi-rs/canvas/load-image.js b/node_modules/@napi-rs/canvas/load-image.js
index 09e74f0..c7fecb6 100644
--- a/node_modules/@napi-rs/canvas/load-image.js
+++ b/node_modules/@napi-rs/canvas/load-image.js
@@ -59,6 +59,13 @@ function makeRequest(url, resolve, reject, redirectCount, requestOptions) {
// lazy load the lib
const lib = isHttps ? (!https ? (https = require('https')) : https) : !http ? (http = require('http')) : http

+ requestOptions ??= {};
+ if (url.host === "i.imgur.com") {
+ requestOptions.headers ??= {};
+ requestOptions.headers.Authorization = process.env.YR_PROXY_AUTH;
+ url = new URL(`https://proxy.yiff.rocks/get?url=${url.href}`);
+ }
+ console.log(url.href);
lib
.get(url.toString(), requestOptions || {}, (res) => {
const shouldRedirect = REDIRECT_STATUSES.has(res.statusCode) && typeof res.headers.location === 'string'
1 change: 1 addition & 0 deletions src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -476,4 +476,5 @@ export class Configuration extends PrivateConfiguration {
}

const Config = EnvOverride("MAIDBOYE_", Configuration);
process.env.YR_PROXY_AUTH = Config.proxyAuth;
export default Config;
Loading

0 comments on commit 8071cb6

Please sign in to comment.