Skip to content

Commit afaf444

Browse files
committed
fix cors function for alpine linux
1 parent 96c18ec commit afaf444

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

js/server_functions.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const dns = require("node:dns");
22
const fs = require("node:fs");
33
const path = require("node:path");
44
const ipaddr = require("ipaddr.js");
5-
const { Agent } = require("undici");
5+
const { fetch, Agent } = require("undici");
66
const Log = require("logger");
77

88
const startUp = new Date();
@@ -98,7 +98,10 @@ async function cors (req, res) {
9898
}
9999

100100
// Pin the validated IP — fetch() reuses it instead of doing its own DNS lookup
101-
const dispatcher = new Agent({ connect: { lookup: (_h, _o, cb) => cb(null, address, family) } });
101+
const dispatcher = new Agent({ connect: { lookup: (_h, _o, cb) => {
102+
const addresses = [{ address: address, family: family }];
103+
process.nextTick(() => cb(null, addresses));
104+
}} });
102105

103106
const response = await fetch(url, { dispatcher, headers: headersToSend });
104107
if (response.ok) {

0 commit comments

Comments
 (0)