Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"type": "module",
"private": true,
"packageManager": "pnpm@9.15.2",
"packageManager": "pnpm@10.21.0",
"engines": {
"node": ">=20.10.0"
},
Expand Down
19 changes: 9 additions & 10 deletions packages/cli-kit/lib/node/http.ts
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down Expand Up @@ -42,9 +41,9 @@ async function request<T>(endpoint: string, options: RequestInit = {}): Promise<
}

export async function get<T>(endpoint: string, options: RequestInit = {}): Promise<T> {
return request<T>(`${scheme()}://${endpoint}`, { ...options, method: 'GET' });
return request<T>(`https://${endpoint}`, { ...options, method: 'GET' });
}

export async function post<T>(endpoint: string, options: RequestInit = {}): Promise<T> {
return request<T>(`${scheme()}://${endpoint}`, { ...options, method: 'POST' });
return request<T>(`https://${endpoint}`, { ...options, method: 'POST' });
}
6 changes: 3 additions & 3 deletions packages/theme/lib/cli/services/dev/worker.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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'],
},
});
Expand All @@ -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);
Expand Down