Skip to content

refactor(translate): 翻訳を共通 cors-proxy 経由に統一し translate 専用 Lambda を obsolete 化 (#862)#864

Merged
takaokouji merged 1 commit into
developfrom
topic/autopilot-862
Jul 1, 2026
Merged

refactor(translate): 翻訳を共通 cors-proxy 経由に統一し translate 専用 Lambda を obsolete 化 (#862)#864
takaokouji merged 1 commit into
developfrom
topic/autopilot-862

Conversation

@smalruby3-editor-bot

Copy link
Copy Markdown

Summary

翻訳拡張 (scratch3_translate) の CORS 回避を、専用 Lambda (/scratch-api-proxy/translate) では
なく Smalruby の汎用 cors-proxy (GET /cors-proxy?url=<encoded 翻訳URL>) の再利用に統一する。
これは #861 の text2speech と同じ設計思想で、translate 専用 Lambda は obsolete になる。

Changes Made

  • packages/scratch-vm/src/extensions/scratch3_translate/index.js
    • serverURL を upstream の値 (https://translate-service.scratch.mit.edu/) に戻した
      (upstream 定数は変えず、fetch 直前でラップ → upstream merge の衝突を最小化)。
    • CORS_PROXY_HOST = 'https://api.smalruby.app/cors-proxy' を追加。
    • getTranslate の URL 組み立て箇所で、最終 URL を
      ${CORS_PROXY_HOST}?url=${encodeURIComponent(翻訳URL)} にラップしてから fetch。
    • Smalruby マーカー (translate CORS proxy) を汎用プロキシ方式に更新。
  • docs/maintenance/smalruby-markers-vm.md: translate CORS proxy マーカーの説明を更新。
  • docs/infra/smalruby-api.md: /scratch-api-proxy/translateobsolete と明記
    (Lambda コード / CDK ルートは deploy を伴うため今回は残置)。

Test Coverage

  • test/unit/extension_translate_proxy.js を cors-proxy 経路の検証に更新
    (fetch URL が cors-proxy?url= 経由で、CORS-locked な translate サービスを直叩きしないこと)。
  • cd packages/scratch-vm && npm exec tap -- test/unit/extension_translate_proxy.js --disable-coverage → 4/4 緑。
  • npm run lint → 0 errors(残る 3 warnings は本 PR で触れていない test ファイルの既存分)。

Notes

Related Issues

Closes #862

🤖 Generated with Claude Code

翻訳拡張 (scratch3_translate) の CORS 回避を専用 Lambda (`/scratch-api-proxy/translate`) では

なく Smalruby の汎用 cors-proxy (`GET /cors-proxy?url=<encoded 翻訳URL>`) の再利用に統一する

(#861 の text2speech と同方式)。translate 専用 Lambda は obsolete になる。

- scratch3_translate/index.js: serverURL を upstream 値に戻し、翻訳 URL 組み立て箇所だけ

  generic cors-proxy でラップ (Smalruby マーカーで囲む)。upstream 差分が最小化。

- test/unit/extension_translate_proxy.js: cors-proxy 経路を検証するよう更新。

- docs (infra/smalruby-api / maintenance/markers-vm) を汎用プロキシ方式に更新し、

  translate 専用 Lambda が obsolete である旨を明記。

- Lambda コード/CDK ルートは deploy を伴うため今回は残置。

Closes #862

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@smalruby3-editor-bot smalruby3-editor-bot Bot added the 🤖 autopilot autopilot(AI)が管理する PR/Issue(AI処理対象) label Jul 1, 2026
@smalruby3-editor-bot

smalruby3-editor-bot Bot commented Jul 1, 2026

Copy link
Copy Markdown
Author

🤖 autopilot status

field value
Status Review
AI Status
HITL Yes
Size small

Linked issue #862. Maintained by autopilot (single writer); do not edit.

@smalruby3-editor-bot smalruby3-editor-bot Bot added the 🙋 HITL 人間の対応待ち(レビュー/判断/マージ) label Jul 1, 2026
@smalruby3-editor-bot smalruby3-editor-bot Bot marked this pull request as ready for review July 1, 2026 14:17
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

🚀 Preview deployed: https://smalruby.jp/smalruby3-editor/topic/autopilot-862/

@takaokouji takaokouji merged commit a333354 into develop Jul 1, 2026
9 checks passed
@takaokouji takaokouji deleted the topic/autopilot-862 branch July 1, 2026 15:37
github-actions Bot pushed a commit that referenced this pull request Jul 1, 2026
…ot-862

refactor(translate): 翻訳を共通 cors-proxy 経由に統一し translate 専用 Lambda を obsolete 化 (#862)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🤖 autopilot autopilot(AI)が管理する PR/Issue(AI処理対象) 🙋 HITL 人間の対応待ち(レビュー/判断/マージ)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor(translate): 翻訳を共通 cors-proxy 経由に統一し translate 専用 Lambda を obsolete 化

1 participant