diff --git a/package.json b/package.json index 2bae1cc..fb58202 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "type": "module", "private": true, - "packageManager": "pnpm@9.15.2", + "packageManager": "pnpm@10.21.0", "engines": { "node": ">=20.10.0" }, diff --git a/packages/cli-kit/lib/node/http.ts b/packages/cli-kit/lib/node/http.ts index bc9aa69..a506879 100644 --- a/packages/cli-kit/lib/node/http.ts +++ b/packages/cli-kit/lib/node/http.ts @@ -1,18 +1,17 @@ import type { RequestInit } from 'node-fetch'; +import https from 'node:https'; +import process from 'node:process'; import { isJson } from '@/common/string'; import fetch from 'node-fetch'; import { is, mergeDeepLeft } from 'ramda'; -import { Session } from '..'; -import * as Env from './env'; - -export function scheme(): 'http' | 'https' { - return Env.get('HOST_ENV') === 'dev' ? 'http' : 'https'; -} +import { Env, Session } from '..'; async function agent() { - const { Agent } = await import(scheme()); + if (Env.get('HOST_ENV') === 'dev') { + process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'; + } - return new Agent({ keepAlive: true, keepAliveMsecs: 5 * 60 * 1000 }); + return new https.Agent({ keepAlive: true, keepAliveMsecs: 5 * 60 * 1000 }); } async function defaults() { @@ -42,9 +41,9 @@ async function request(endpoint: string, options: RequestInit = {}): Promise< } export async function get(endpoint: string, options: RequestInit = {}): Promise { - return request(`${scheme()}://${endpoint}`, { ...options, method: 'GET' }); + return request(`https://${endpoint}`, { ...options, method: 'GET' }); } export async function post(endpoint: string, options: RequestInit = {}): Promise { - return request(`${scheme()}://${endpoint}`, { ...options, method: 'POST' }); + return request(`https://${endpoint}`, { ...options, method: 'POST' }); } diff --git a/packages/theme/lib/cli/services/dev/worker.ts b/packages/theme/lib/cli/services/dev/worker.ts index 2829769..84dac80 100644 --- a/packages/theme/lib/cli/services/dev/worker.ts +++ b/packages/theme/lib/cli/services/dev/worker.ts @@ -1,7 +1,7 @@ import type { Store, Theme } from '@/types'; import type { ThemeCommand } from '@/util/theme-command'; import { THEME_FILE_TYPES } from '@/constants'; -import { Filesystem, Http, Path, System, Worker } from '@youcan/cli-kit'; +import { Filesystem, Path, System, Worker } from '@youcan/cli-kit'; import debounce from 'debounce'; import { Server } from 'socket.io'; import { execute } from './execute'; @@ -28,7 +28,7 @@ export default class ThemeWorker extends Worker.Abstract { try { this.io = new Server(7565, { cors: { - origin: `${Http.scheme()}://${this.store.domain}`, + origin: `https://${this.store.domain}`, methods: ['GET', 'POST'], }, }); @@ -37,7 +37,7 @@ export default class ThemeWorker extends Worker.Abstract { this.previewLogger.write(`attached to preview page at ${socket.handshake.address}`); }); - System.open(`${Http.scheme()}://${this.store.domain}/themes/${this.theme.theme_id}/preview`); + System.open(`https://${this.store.domain}/themes/${this.theme.theme_id}/preview`); } catch (err) { this.command.error(err as Error);