Skip to content

Commit 08e82b8

Browse files
committed
feat: add support custom cookie
1 parent 52cd2fb commit 08e82b8

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class NHentaiAPI(opts?: Options)
3333
type Options = {
3434
timeout?: number // http request timeout (optional)
3535
userAgent?: string // http request User-Agent header (optional)
36+
cookie?: string // http request cookie (optional)
3637
proxy?: { // http proxy (optional)
3738
host: string // proxy host (required)
3839
port: number // porxy port (required)

src/api.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export const IMAGE_SUFFIX_TYPES: Record<ImageType | ImageSuffix, ImageSuffix> =
3232
export type Options = Partial<{
3333
timeout: number
3434
userAgent: string
35+
cookie?: string
3536
proxy: {
3637
host: string
3738
port: number
@@ -53,7 +54,10 @@ export class NHentaiAPI {
5354
https: httpsOverHttp({ proxy: opts.proxy }) as any
5455
}
5556
: undefined,
56-
headers: { 'user-agent': opts.userAgent || DEFAULT_UA },
57+
headers: {
58+
'user-agent': opts.userAgent || DEFAULT_UA,
59+
cookie: opts.cookie
60+
},
5761
hooks: debug.enabled
5862
? {
5963
beforeRequest: [

0 commit comments

Comments
 (0)