Skip to content

文档站还有两处环境变量示例与实现不符:runner.mdx 教两个 runner 不读的变量,objectos-integration.mdx 在 Vite 前端用 process.env #3533

Description

@yinlianghui

越界发现,记录于 #3527(把 deployment.md / console.md 改教真变量 VITE_SERVER_URL)期间,对 content/ 做全量 VITE_API_URL 复查时。未在 PR #3532 中顺手修改(该 PR 的文件面严格锁在 content/docs/guide/deployment.mdcontent/docs/guide/console.md)。

#3527 修掉的是两个页面;同一次 grep 显示 content/ 里还剩 5 处 VITE_API_URL,逐一核对后分成两类。

一、content/docs/utilities/runner.mdx:319-330 —— 与 #3527 完全同类的死变量

## Environment Variables

Configure the runner with environment variables:

# .env
VITE_API_URL=http://localhost:3000
VITE_APP_TITLE="ObjectUI Runner"

Use in code:
const apiUrl = import.meta.env.VITE_API_URL

实测 @object-ui/runner 一个环境变量都不读:

$ grep -rn "import.meta.env\|process.env" packages/runner/src
(无输出)

$ grep -rn "VITE_APP_TITLE" -I . | grep -v node_modules
content/docs/utilities/runner.mdx:323          ← 全仓仅此一处,即只存在于这份文档里

$ grep -rn "VITE_API_URL" packages/ apps/ examples/ scripts/ | grep -v node_modules
(无输出)

所以「Configure the runner with environment variables」这一整节教的两个变量,runner 都不会读。这与 #3527 是同一种失败形态:读者照做、配了、没有任何报错、也没有任何效果

二、content/docs/guide/objectos-integration.mdx:404-407 —— 前端代码里用 process.env

// frontend/src/config.ts
export const config = {
  apiBaseUrl: process.env.VITE_API_URL || 'http://localhost:3000/api'
};

注释明写这是 frontend/,而 Vite 默认不注入 process,该行在浏览器里会直接 process is not defined(或恒为 undefined,静默退回硬编码的 http://localhost:3000/api)。前端侧的正确拼法是 import.meta.env.VITE_API_URL

这一处与第一类不同:变量名本身是读者自己应用里的自定义变量(不是 ObjectUI 的契约),问题只出在读取方式。

三、核对后判定「没问题、不要改」的一处

content/docs/guide/building-crud-app.md:306:

const dataSource = new RestDataSource(
  import.meta.env.VITE_API_URL || 'http://localhost:3000/api'
);

这是读者在自己的应用里自定义一个变量、再用自己的 import.meta.env 读它,拼法也对。属正常示例,不应一并"修"掉 —— 记在这里是为了让后续处理的人不要把它当成同一批。

建议

第一类按 #3527 的口径处理:runner 若确实没有环境变量配置面,整节删除,而不是换个变量名;若本该有(如 runner 需要一个 API 基址),那是缺失的实现,应另立实现单。第二类是一处 process.envimport.meta.env 的改法修正。

备注

#3527 的席位纪律,查重由 PM 座位统一执行(共享 GitHub 身份有速率限制,dev 席位不重复 search)。若已有同源单请 race-close 本单。


Generated by Claude Code

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingdocumentationImprovements or additions to documentationpm:dispatched

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions