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: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ package-lock.json

# Camoufox browser
camoufox/
camoufox-linux/
camoufox-macos/
camoufox*.zip

# Authentication files
Expand Down
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@

## 🚀 快速开始

### 💻 本地运行(仅支持 Windows)
### 💻 本地运行(Windows / macOS / Linux

1. 克隆仓库:

```powershell
```bash
git clone https://github.com/iBenzene/AIStudioToAPI.git
cd AIStudioToAPI
```

2. 运行快速设置脚本:

```powershell
```bash
npm run setup-auth
```

Expand All @@ -40,16 +40,15 @@ npm run setup-auth

3. 启动服务:

```powershell
npm install
```bash
npm start
```

API 服务将在 `http://localhost:7860` 上运行。

服务启动后,您可以在浏览器中访问 `http://localhost:7860` 打开 Web 控制台主页,在这里可以查看账号状态和服务状态。

> ⚠ **注意:** Windows 本地运行不支持通过 VNC 在线添加账号,需要使用 `npm run setup-auth` 脚本添加账号。当前 VNC 登录功能仅在 Linux 服务器上的 Docker 容器中可用。
> ⚠ **注意:** 本地运行不支持通过 VNC 在线添加账号,需要使用 `npm run setup-auth` 脚本添加账号。当前 VNC 登录功能仅在 Linux 服务器上的 Docker 容器中可用。

### ☁ 云端部署(Linux VPS)

Expand Down Expand Up @@ -131,7 +130,7 @@ sudo docker compose down

**方法 2:上传认证文件**

- 在 Windows 机器上运行 `npm run setup-auth` 生成认证文件
- 在本地机器上运行 `npm run setup-auth` 生成认证文件
- 在网页控制台,点击「上传 Auth」,上传 auth 的 JSON 文件,或手动上传到挂载的 `/path/to/auth` 目录

> 💡 **提示**:您也可以从已有的服务器下载 auth 文件,然后上传到新的服务器。在网页控制台点击对应账号的「下载 Auth」按钮即可下载 auth 文件。
Expand Down
13 changes: 6 additions & 7 deletions README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@ A tool that wraps Google AI Studio web interface to provide OpenAI API and Gemin

## 🚀 Quick Start

### 💻 Local Development (Windows Only)
### 💻 Local Development (Windows / macOS / Linux)

1. Clone the repository:

```powershell
```bash
git clone https://github.com/iBenzene/AIStudioToAPI.git
cd AIStudioToAPI
```

2. Run the setup script:

```powershell
```bash
npm run setup-auth
```

Expand All @@ -40,16 +40,15 @@ This script will:

3. Start the service:

```powershell
npm install
```bash
npm start
```

The API server will be available at `http://localhost:7860`

After the service starts, you can access `http://localhost:7860` in your browser to open the web console homepage, where you can view account status and service status.

> ⚠ **Note:** Windows local deployment does not support adding accounts via VNC online. You need to use the `npm run setup-auth` script to add accounts. VNC login is only available in Docker deployments on Linux servers.
> ⚠ **Note:** Local deployment does not support adding accounts via VNC online. You need to use the `npm run setup-auth` script to add accounts. VNC login is only available in Docker deployments on Linux servers.

### ☁ Cloud Deployment (Linux VPS)

Expand Down Expand Up @@ -131,7 +130,7 @@ After deployment, you need to add Google accounts using one of these methods:

**Method 2: Upload Auth Files**

- Run `npm run setup-auth` on a Windows machine to generate auth files
- Run `npm run setup-auth` on your local machine to generate auth files
- In the web console, click "Upload Auth" to upload the auth JSON file, or manually upload to the mounted `/path/to/auth` directory

> 💡 **Tip**: You can also download auth files from an existing server and upload them to a new server. Click the "Download Auth" button for the corresponding account in the web console to download the auth file.
Expand Down
1 change: 1 addition & 0 deletions docs/en/claw-cloud-run.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ After deployment, you need to add Google accounts. There are two methods:
**Method 2: Upload Auth Files**

- Run `npm run setup-auth` on a Windows machine to generate auth files
- Run `npm run setup-auth` on your local machine to generate auth files
- In the web console, click "Upload Auth" to upload the auth JSON file

> 💡 **Tip**: You can also download auth files from an existing server and upload them to a new server. Click the "Download Auth" button for the corresponding account in the web console to download the auth file.
Expand Down
2 changes: 1 addition & 1 deletion docs/en/zeabur.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ After deployment, you need to add Google accounts. There are two methods:

**Method 2: Upload Auth Files**

- Run `npm run setup-auth` on a Windows machine to generate auth files
- Run `npm run setup-auth` on your local machine to generate auth files
- In the web console, click "Upload Auth" to upload the auth JSON file

> 💡 **Tip**: You can also download auth files from an existing server and upload them to a new server. Click the "Download Auth" button for the corresponding account in the web console to download the auth file.
Expand Down
2 changes: 1 addition & 1 deletion docs/zh/claw-cloud-run.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@

**方法 2:上传认证文件**

- 在 Windows 机器上运行 `npm run setup-auth` 生成认证文件
- 在本地机器上运行 `npm run setup-auth` 生成认证文件
- 在网页控制台,点击「上传 Auth」,上传 auth 的 JSON 文件

> 💡 **提示**:您也可以从已有的服务器下载 auth 文件,然后上传到新的服务器。在网页控制台点击对应账号的「下载 Auth」按钮即可下载 auth 文件。
Expand Down
2 changes: 1 addition & 1 deletion docs/zh/zeabur.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@

**方法 2:上传认证文件**

- 在 Windows 机器上运行 `npm run setup-auth` 生成认证文件
- 在本地机器上运行 `npm run setup-auth` 生成认证文件
- 在网页控制台,点击「上传 Auth」,上传 auth 的 JSON 文件

> 💡 **提示**:您也可以从已有的服务器下载 auth 文件,然后上传到新的服务器。在网页控制台点击对应账号的「下载 Auth」按钮即可下载 auth 文件。
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"start": "cross-env NODE_ENV=production node main.js",
"prestart": "npm run build:ui",
"save-auth": "node scripts/auth/saveAuth.js",
"setup-auth": "scripts\\auth\\setupAuth.bat",
"setup-auth": "node scripts/auth/setupAuth.js",
"prepare": "husky install",
"lint": "eslint . && stylelint \"ui/**/*.{css,less}\"",
"lint:fix": "eslint . --fix && stylelint \"ui/**/*.{css,less}\" --fix",
Expand Down
19 changes: 18 additions & 1 deletion scripts/auth/saveAuth.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,20 @@

const { firefox } = require("playwright");
const fs = require("fs");
const os = require("os");
const path = require("path");

// --- Configuration Constants ---
const browserExecutablePath = path.join(__dirname, "..", "..", "camoufox", "camoufox.exe");
const getDefaultBrowserExecutablePath = () => {
const platform = os.platform();
if (platform === "linux") return path.join(__dirname, "..", "..", "camoufox-linux", "camoufox");
if (platform === "win32") return path.join(__dirname, "..", "..", "camoufox", "camoufox.exe");
if (platform === "darwin")
return path.join(__dirname, "..", "..", "camoufox-macos", "Camoufox.app", "Contents", "MacOS", "camoufox");
return null;
};

const browserExecutablePath = process.env.CAMOUFOX_EXECUTABLE_PATH || getDefaultBrowserExecutablePath();
const VALIDATION_LINE_THRESHOLD = 200; // Validation line threshold
const CONFIG_DIR = "configs/auth"; // Authentication files directory

Expand Down Expand Up @@ -59,6 +69,13 @@ const getNextAuthIndex = () => {
console.log(`▶️ Preparing to create new authentication file for account #${newIndex}...`);
console.log(`▶️ Launching browser: ${browserExecutablePath}`);

if (!browserExecutablePath || !fs.existsSync(browserExecutablePath)) {
console.error("❌ Camoufox executable not found.");
console.error(` -> Checked: ${browserExecutablePath || "(null)"}`);
console.error(' -> Please run "npm run setup-auth" first, or set CAMOUFOX_EXECUTABLE_PATH.');
process.exit(1);
}

const browser = await firefox.launch({
executablePath: browserExecutablePath,
headless: false,
Expand Down
Loading