Skip to content

Commit 458cddb

Browse files
authored
feat: enable first hit to origin (#45)
* feat: enable first hit to origin * fix: type description
1 parent 1dacecc commit 458cddb

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/client.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,13 @@ export class Saturn {
308308
}
309309

310310
let fallbackCount = 0
311-
const nodes = this.nodes
311+
let nodes = this.nodes
312+
if (opts.firstHitDNS) {
313+
nodes = [
314+
{ url: this.config.cdnURL },
315+
...nodes
316+
]
317+
}
312318
for (let i = 0; i < nodes.length; i++) {
313319
if (fallbackCount > this.config.fallbackLimit || skipNodes || upstreamController?.signal.aborted) {
314320
break

src/types.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
* @property {string} [jwt] - JWT for L1 request.
2525
* @property {number} [connectTimeout=5000] - Connection timeout in milliseconds.
2626
* @property {number} [downloadTimeout=0] - Download timeout in milliseconds.
27-
* @property {AbortController} [controller]
27+
* @property {AbortController} [controller] - Abort controller
28+
* @property {boolean} [firstHitDNS] - First request hit is always to CDN origin.
2829
*/
2930

3031
export {}

0 commit comments

Comments
 (0)