@kevisual/cnb 0.0.18 → 0.0.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/opencode.js CHANGED
@@ -22517,6 +22517,7 @@ class CNBCore {
22517
22517
  hackURL = API_HACK_URL;
22518
22518
  token;
22519
22519
  cookie;
22520
+ isCors;
22520
22521
  constructor(options) {
22521
22522
  this.token = options.token;
22522
22523
  this.cookie = options.cookie;
@@ -22532,6 +22533,7 @@ class CNBCore {
22532
22533
  this.baseURL = options.cors.baseUrl + "/" + API_BASER_URL.replace("https://", "");
22533
22534
  this.hackURL = options.cors.baseUrl + "/" + API_HACK_URL.replace("https://", "");
22534
22535
  }
22536
+ this.isCors = !!options?.cors?.baseUrl;
22535
22537
  }
22536
22538
  async request({ url: url2, method = "GET", data, params, headers, body, useCookie, useOrigin }) {
22537
22539
  const defaultHeaders = {
@@ -22558,9 +22560,14 @@ class CNBCore {
22558
22560
  delete _headers.Authorization;
22559
22561
  }
22560
22562
  if (useCookie) {
22561
- _headers["Cookie"] = this.cookie || "";
22563
+ if (this.isCors) {
22564
+ _headers["app-cookie"] = this.cookie || "";
22565
+ } else {
22566
+ _headers["Cookie"] = this.cookie || "";
22567
+ }
22562
22568
  delete _headers.Authorization;
22563
22569
  }
22570
+ console.log("Request URL:", url2, data, _headers);
22564
22571
  const response = await fetch(url2 || "", {
22565
22572
  method,
22566
22573
  headers: _headers,
package/dist/routes.d.ts CHANGED
@@ -28,6 +28,7 @@ declare class CNBCore {
28
28
  hackURL: string;
29
29
  token: string;
30
30
  cookie?: string;
31
+ isCors: boolean;
31
32
  constructor(options: CNBCoreOptions);
32
33
  request({ url, method, data, params, headers, body, useCookie, useOrigin }: RequestOptions): Promise<any>;
33
34
  makeUrl(url?: string): string;
package/dist/routes.js CHANGED
@@ -22517,6 +22517,7 @@ class CNBCore {
22517
22517
  hackURL = API_HACK_URL;
22518
22518
  token;
22519
22519
  cookie;
22520
+ isCors;
22520
22521
  constructor(options) {
22521
22522
  this.token = options.token;
22522
22523
  this.cookie = options.cookie;
@@ -22532,6 +22533,7 @@ class CNBCore {
22532
22533
  this.baseURL = options.cors.baseUrl + "/" + API_BASER_URL.replace("https://", "");
22533
22534
  this.hackURL = options.cors.baseUrl + "/" + API_HACK_URL.replace("https://", "");
22534
22535
  }
22536
+ this.isCors = !!options?.cors?.baseUrl;
22535
22537
  }
22536
22538
  async request({ url: url2, method = "GET", data, params, headers, body, useCookie, useOrigin }) {
22537
22539
  const defaultHeaders = {
@@ -22558,9 +22560,14 @@ class CNBCore {
22558
22560
  delete _headers.Authorization;
22559
22561
  }
22560
22562
  if (useCookie) {
22561
- _headers["Cookie"] = this.cookie || "";
22563
+ if (this.isCors) {
22564
+ _headers["app-cookie"] = this.cookie || "";
22565
+ } else {
22566
+ _headers["Cookie"] = this.cookie || "";
22567
+ }
22562
22568
  delete _headers.Authorization;
22563
22569
  }
22570
+ console.log("Request URL:", url2, data, _headers);
22564
22571
  const response = await fetch(url2 || "", {
22565
22572
  method,
22566
22573
  headers: _headers,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kevisual/cnb",
3
- "version": "0.0.18",
3
+ "version": "0.0.19",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/cnb-core.ts CHANGED
@@ -27,6 +27,7 @@ export class CNBCore {
27
27
  hackURL = API_HACK_URL;
28
28
  public token: string;
29
29
  public cookie?: string;
30
+ isCors: boolean;
30
31
  constructor(options: CNBCoreOptions) {
31
32
  this.token = options.token;
32
33
  this.cookie = options.cookie;
@@ -42,6 +43,7 @@ export class CNBCore {
42
43
  this.baseURL = options.cors.baseUrl + '/' + API_BASER_URL.replace('https://', '');
43
44
  this.hackURL = options.cors.baseUrl + '/' + API_HACK_URL.replace('https://', '');
44
45
  }
46
+ this.isCors = !!options?.cors?.baseUrl;
45
47
  }
46
48
 
47
49
  async request({ url, method = 'GET', data, params, headers, body, useCookie, useOrigin }: RequestOptions): Promise<any> {
@@ -70,10 +72,14 @@ export class CNBCore {
70
72
  delete _headers.Authorization;
71
73
  }
72
74
  if (useCookie) {
73
- _headers['Cookie'] = this.cookie || "";
75
+ if (this.isCors) {
76
+ _headers['app-cookie'] = this.cookie || "";
77
+ } else {
78
+ _headers['Cookie'] = this.cookie || "";
79
+ }
74
80
  delete _headers.Authorization;
75
81
  }
76
- // console.log('Request URL:', url, data, _headers);
82
+ console.log('Request URL:', url, data, _headers);
77
83
  const response = await fetch(url || '', {
78
84
  method,
79
85
  headers: _headers,