Skip to content

fix: API test console sends requests to the selected data source, not the page origin - #614

Open
zjncs wants to merge 1 commit into
oss-compass:mainfrom
zjncs:fix/api-console-origin
Open

zjncs wants to merge 1 commit into
oss-compass:mainfrom
zjncs:fix/api-console-origin

Conversation

@zjncs

@zjncs zjncs commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Problem

Two coupled issues in the API documentation test console (modules/dataHub):

1. Requests go to the page origin, not the selected data source. EndpointTab's DataSourceSelector lets the user pick one of three origins (oss-compass.org / isrc / osslab-pku), but the selected value only feeds the displayed code block. ParamsTableWithForm never receives it — the test request uses a bare relative path, which axios resolves against window.location.origin. The UI advertises https://oss-compass.isrc.ac.cn/api/v2/... while the request actually hits the current site's backend.

2. Debug console.log leaks the user's access_token on every request. console.log(values) dumps the complete form values — including the user's API key — to the browser console in production. Plus a per-param debug log block.

Fix

  1. Pass baseUrl from EndpointTab to ParamsTableWithForm; prepend it in constructUrl.
  2. Remove the three debug console.log calls.

Verification

  • New EndpointTab.test.tsx (mocked children): asserts ParamsTableWithForm receives baseUrl: 'https://oss-compass.isrc.ac.cn' alongside path/method — RED before (no baseUrl prop existed), GREEN after.
  • tsc --noEmit: zero errors in the touched files (pre-existing SVG module-declaration errors elsewhere unchanged).

Risk

The test console now actually tests against the origin the user selected — previously it silently tested against whichever site the user was browsing.

… the page origin

EndpointTab 的 DataSourceSelector 选中的 origin 只用于展示代码块,
ParamsTableWithForm 从未收到它——测试请求用相对路径构造,axios
解析到页面 origin(window.location.origin)而非选中的数据源。
默认状态下 UI 显示 https://oss-compass.isrc.ac.cn/api/v2/... 而
请求实际打到当前站点后端。

同时移除 ParamsTableWithForm 的三处 debug console.log——其中
console.log(values) 在每次"发送请求"时将用户的 access_token
(API 密钥)完整输出到浏览器控制台。

baseUrl 从 EndpointTab 传入并用于 constructUrl。
Copilot AI balanced review requested due to automatic review settings October 22, 2026 08:25
@vercel

vercel Bot commented Oct 22, 2026

Copy link
Copy Markdown

@zjncs is attempting to deploy a commit to the codersett's projects Team on Vercel.

A member of the Team first needs to authorize it.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants