fix(auth): 修復遠端部署登入失敗問題 v0.1.7

## Bug Fixes
- Cookie sameSite 從 strict 改為 lax(修復遠端存取問題)
- 新增 Cookie path 設定確保覆蓋整個應用
- 新增 TRUST_PROXY 環境變數支援 reverse proxy

## Features
- Dockerfile 新增 texlive-lang-arabic/other(阿拉伯/希伯來語)
- Dockerfile 新增 python3-opencv(電腦視覺)
- Dockerfile 新增 libavcodec-extra(額外編解碼器)
- Locale 預設改為 zh_TW.UTF-8
- Pandoc PDF 引擎改用 pdflatex

## Docs
- compose.yaml 新增 TRUST_PROXY 說明
- 新增遠端部署注意事項
This commit is contained in:
Your Name 2026-01-20 14:11:11 +08:00
parent 44152ff872
commit 03be03bbc2
6 changed files with 87 additions and 59 deletions

View file

@ -1,5 +1,31 @@
# Changelog
## [0.1.7](https://github.com/pi-docket/ConvertX-CN/releases/tag/v0.1.7) (2026-01-20)
### 🐛 Bug Fixes
- **登入問題**: 修復遠端部署時登入後被導回登入頁的問題
- 將 Cookie `sameSite``strict` 改為 `lax`
- 新增 Cookie `path` 設定確保覆蓋整個應用
- 新增 `TRUST_PROXY` 環境變數支援 reverse proxy
### 🚀 Features
- **Dockerfile 擴充**: 直接內建進階功能(不再分 Full 版)
- 新增 `texlive-lang-arabic` 阿拉伯語 LaTeX 支援
- 新增 `texlive-lang-other` 希伯來語等 LaTeX 支援
- 新增 `python3-opencv` 電腦視覺轉換支援
- 新增 `libavcodec-extra` 額外影片編解碼器
- **Locale**: 預設改為 `zh_TW.UTF-8` 確保中文 PDF 正確顯示
- **Pandoc**: PDF 引擎改用 `pdflatex` 提高相容性
### 📝 Docs
- 更新 compose.yaml 加入 `TRUST_PROXY` 說明
- 新增遠端部署注意事項
---
## [0.1.6](https://github.com/pi-docket/ConvertX-CN/releases/tag/v0.1.6) (2026-01-20)
### Features

View file

@ -1,23 +1,19 @@
# ==============================================================================
# ConvertX-CN 官方 Docker Image
# 版本v0.1.6
# 版本v0.1.7
# ==============================================================================
#
# 📦 Image 說明:
# - 這是 ConvertX-CN 官方 Docker Hub Image 的生產 Dockerfile
# - 目標:在功能完整性與 image 體積間取得平衡
# - 適合一般使用者日常文件轉換需求
# - 已內建完整功能,無需額外擴充
#
# 🌍 內建語言支援:
# - OCR: 英文、繁體中文、簡體中文、日文、韓文、德文、法文
# - Locale: en_US, zh_TW, zh_CN, ja_JP, ko_KR, de_DE, fr_FR
# - 字型: Noto CJK, Liberation, 自訂中文字型
# - 字型: Noto CJK, Liberation, 標楷體
# - LaTeX: CJK、德文、法文、阿拉伯語、希伯來語
#
# 📊 Image 大小:約 4-6 GB
#
# 💡 如需完整 65 種 OCR 語言或進階功能,請參考:
# - Dockerfile.full (完整版,使用者自行 build)
# - 文件docs/docker.md
# 📊 Image 大小:約 5-7 GB
#
# ==============================================================================
@ -73,14 +69,11 @@ FROM base AS release
# ==============================================================================
#
# ✅ 核心轉換工具:完整保留
# ✅ TexLive最小集合(支援 CJK、德文、法文
# ✅ TexLive完整 CJK + 德法 + 阿拉伯/希伯來語
# ✅ OCR7 種主要語言
# ✅ 字型Noto CJK + Liberation
#
# ❌ 未內建(體積過大,請參考 Dockerfile.full
# - texlive-full約 +3GB
# - 65 種 OCR 語言(約 +2GB
# - fonts-noto-extra約 +500MB
# ✅ 字型Noto CJK + Liberation + 標楷體
# ✅ OpenCV電腦視覺轉換支援
# ✅ 額外影片編解碼器
#
# ==============================================================================
RUN apt-get update && apt-get install -y --no-install-recommends \
@ -104,17 +97,11 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
poppler-utils \
potrace \
resvg \
# === 額外影片編解碼器 ===
libavcodec-extra \
# === LibreOffice (headless) ===
libreoffice \
# === TexLive 最小集合(取代 texlive-full===
# texlive-base: LaTeX 核心
# texlive-latex-base: 基本 LaTeX 類別
# texlive-latex-recommended: 常用套件geometry, hyperref 等)
# texlive-fonts-recommended: 基本字型Computer Modern 等)
# texlive-xetex: XeTeX 引擎Unicode/CJK 支援必需)
# texlive-lang-cjk: 中日韓 LaTeX 支援
# texlive-lang-german: 德文 LaTeX 支援
# texlive-lang-french: 法文 LaTeX 支援
# === TexLive 完整語言支援 ===
texlive-base \
texlive-latex-base \
texlive-latex-recommended \
@ -123,17 +110,13 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
texlive-lang-cjk \
texlive-lang-german \
texlive-lang-french \
texlive-lang-arabic \
texlive-lang-other \
latexmk \
lmodern \
# === Pandoc 文件轉換 ===
pandoc \
# === OCR 支援(僅限指定語言)===
# eng: 英文
# chi_tra/chi_sim: 繁/簡中文
# jpn: 日文
# kor: 韓文
# deu: 德文
# fra: 法文
# === OCR 支援7 種語言)===
tesseract-ocr \
tesseract-ocr-eng \
tesseract-ocr-chi-tra \
@ -142,21 +125,17 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
tesseract-ocr-kor \
tesseract-ocr-deu \
tesseract-ocr-fra \
# === 字型(精簡版)===
# fonts-noto-core: Noto Sans/Serif Latin歐語基礎
# fonts-noto-color-emoji: Emoji 支援(僅此一套)
# fonts-liberation: Liberation 字型Arial/Times 替代)
# ❌ 已移除fonts-noto-extra包含過多語言
# ❌ 已移除fonts-liberation2重複
# === 字型 ===
fonts-noto-cjk \
fonts-noto-core \
fonts-noto-color-emoji \
fonts-liberation \
# === Python 依賴(精簡)===
# === Python 依賴 + OpenCV ===
python3 \
python3-pip \
python3-numpy \
python3-tinycss2 \
python3-opencv \
pipx \
# === 系統工具 ===
locales \
@ -179,7 +158,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
ENV PATH="/root/.local/bin:${PATH}"
# ==============================================================================
# 設定 locale僅限指定語言
# 設定 locale支援中文 PDF 避免亂碼
# ==============================================================================
RUN sed -i 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
sed -i 's/# zh_TW.UTF-8 UTF-8/zh_TW.UTF-8 UTF-8/' /etc/locale.gen && \
@ -190,8 +169,9 @@ RUN sed -i 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
sed -i 's/# fr_FR.UTF-8 UTF-8/fr_FR.UTF-8 UTF-8/' /etc/locale.gen && \
locale-gen
ENV LANG=en_US.UTF-8
ENV LC_ALL=en_US.UTF-8
# 預設使用 zh_TW.UTF-8 確保中文 PDF 正確顯示
ENV LANG=zh_TW.UTF-8
ENV LC_ALL=zh_TW.UTF-8
# ==============================================================================
# 安裝自訂字型(標楷體等台灣常用字型)
@ -228,8 +208,8 @@ EXPOSE 3000/tcp
# ==============================================================================
# Calibre 需要
ENV QTWEBENGINE_CHROMIUM_FLAGS="--no-sandbox"
# Pandoc PDF 引擎
ENV PANDOC_PDF_ENGINE=xelatex
# Pandoc PDF 引擎(使用 pdflatex 以獲得最佳相容性)
ENV PANDOC_PDF_ENGINE=pdflatex
# Node 環境
ENV NODE_ENV=production

View file

@ -3,13 +3,18 @@
#
# 🎉 這是完整版 image已內建所有轉換依賴
# - LibreOffice (headless)
# - TexLive Full
# - Tesseract OCR + 中日韓英德語言包
# - CJK 字型Noto CJK、微軟核心字型、標楷體)
# - Pandoc、FFmpeg、ImageMagick 等所有轉換器
# - TexLiveCJK + 阿拉伯/希伯來語)
# - Tesseract OCR + 中日韓英德語言包
# - CJK 字型Noto CJK、標楷體)
# - Pandoc、FFmpeg、ImageMagick、OpenCV 等所有轉換器
#
# ✅ 使用者不需要自己寫 Dockerfile
# ✅ 直接 docker compose up -d 即可使用
#
# ⚠️ 遠端部署注意事項:
# 若透過 Nginx/Traefik 等 reverse proxy 存取,請設定:
# - HTTP_ALLOWED=true若 proxy 處理 HTTPS
# - 或 TRUST_PROXY=true讓應用正確判斷 HTTPS
# ==============================================================================
services:
@ -28,6 +33,7 @@ services:
# === 安全設定 ===
- HTTP_ALLOWED=false # 是否允許非 HTTPS 連線(僅本地測試時設為 true
- TRUST_PROXY=false # 透過 reverse proxy 時設為 true正確判斷 HTTPS
- ALLOW_UNAUTHENTICATED=false # 是否允許未登入使用(僅本地測試時設為 true
# === 檔案管理 ===

View file

@ -1,6 +1,6 @@
{
"name": "convertx-frontend",
"version": "0.1.6",
"version": "0.1.7",
"scripts": {
"dev": "bun run --watch src/index.tsx",
"hot": "bun run --hot src/index.tsx",

View file

@ -3,6 +3,9 @@ export const ACCOUNT_REGISTRATION = process.env.ACCOUNT_REGISTRATION?.toLowerCas
export const HTTP_ALLOWED = process.env.HTTP_ALLOWED?.toLowerCase() === "true" || false;
// Trust proxy headers (X-Forwarded-*) for correct HTTPS detection behind reverse proxy
export const TRUST_PROXY = process.env.TRUST_PROXY?.toLowerCase() === "true" || false;
export const ALLOW_UNAUTHENTICATED =
process.env.ALLOW_UNAUTHENTICATED?.toLowerCase() === "true" || false;

View file

@ -10,12 +10,31 @@ import {
ALLOW_UNAUTHENTICATED,
HIDE_HISTORY,
HTTP_ALLOWED,
TRUST_PROXY,
WEBROOT,
} from "../helpers/env";
import { localeService } from "../i18n/service";
export let FIRST_RUN = db.query("SELECT * FROM users").get() === null || false;
// ==============================================================================
// Cookie 設定輔助函數
// ==============================================================================
// 解決遠端部署時登入失敗的問題:
// 1. sameSite: "lax" - 允許導航時傳送 Cookiestrict 會阻擋)
// 2. path: WEBROOT || "/" - 確保 Cookie 覆蓋整個應用
// 3. secure: 考慮 TRUST_PROXY 設定
// ==============================================================================
function getCookieOptions() {
return {
httpOnly: true,
secure: !HTTP_ALLOWED && !TRUST_PROXY ? true : false,
maxAge: 60 * 60 * 24 * 7, // 7 days
sameSite: "lax" as const,
path: WEBROOT || "/",
};
}
export const userService = new Elysia({ name: "user/service" })
.use(
jwt({
@ -224,13 +243,10 @@ export const user = new Elysia()
};
}
// set cookie
// set cookie with proper options for remote deployment
auth.set({
value: accessToken,
httpOnly: true,
secure: !HTTP_ALLOWED,
maxAge: 60 * 60 * 24 * 7,
sameSite: "strict",
...getCookieOptions(),
});
return redirect(`${WEBROOT}/`, 302);
@ -353,13 +369,10 @@ export const user = new Elysia()
};
}
// set cookie
// set cookie with proper options for remote deployment
auth.set({
value: accessToken,
httpOnly: true,
secure: !HTTP_ALLOWED,
maxAge: 60 * 60 * 24 * 7,
sameSite: "strict",
...getCookieOptions(),
});
return redirect(`${WEBROOT}/`, 302);