[PR #141] [MERGED] fix: resolve CORS for browser extensions & enhance OpenAI Responses compatibility #273

Closed
opened 2026-02-27 07:18:46 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/justlovemaki/AIClient-2-API/pull/141
Author: @yicone
Created: 12/27/2025
Status: Merged
Merged: 12/27/2025
Merged by: @justlovemaki

Base: mainHead: main


📝 Commits (1)

  • 7278293 fix: resolve CORS for browser extensions & enhance OpenAI Responses compatibility

📊 Changes

4 files changed (+188 additions, -8 deletions)

View changed files

📝 src/converters/strategies/OpenAIResponsesConverter.js (+12 -5)
📝 src/request-handler.js (+5 -3)
tests/cors-config.test.js (+91 -0)
tests/openai-responses-converter.test.js (+80 -0)

📄 Description

Description

This PR addresses two issues encountered when integrating with browser extensions (specifically Twemex):

  1. CORS Policy: Applied global CORS headers to allow access from browser extensions (e.g., chrome-extension://...). Previously, the preflight OPTIONS check wasn't sufficient for all extension fetch requests.
  2. Input Format Compatibility: Enhanced OpenAIResponsesConverter to handle input items that:
    • Lack an explicit type property (defaulting to 'message').
    • Use a direct string for content instead of an array of objects.

Context

These issues were discovered while using the Twemex Chrome extension, which relies on the /v1/responses endpoint. The extension sends requests that were previously blocked by CORS and uses a simplified input format that the converter didn't handle.

cc @JimmyLv (Twemex author) - FYI, this enables Twemex compatibility with this project.

Changes

  • Modified src/request-handler.js to set CORS headers on all requests.
  • Updated src/converters/strategies/OpenAIResponsesConverter.js to support flexible input formats.
  • Added tests: tests/cors-config.test.js and tests/openai-responses-converter.test.js.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/justlovemaki/AIClient-2-API/pull/141 **Author:** [@yicone](https://github.com/yicone) **Created:** 12/27/2025 **Status:** ✅ Merged **Merged:** 12/27/2025 **Merged by:** [@justlovemaki](https://github.com/justlovemaki) **Base:** `main` ← **Head:** `main` --- ### 📝 Commits (1) - [`7278293`](https://github.com/justlovemaki/AIClient-2-API/commit/7278293c59e9167bb7cdbbad479c5750a0253034) fix: resolve CORS for browser extensions & enhance OpenAI Responses compatibility ### 📊 Changes **4 files changed** (+188 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `src/converters/strategies/OpenAIResponsesConverter.js` (+12 -5) 📝 `src/request-handler.js` (+5 -3) ➕ `tests/cors-config.test.js` (+91 -0) ➕ `tests/openai-responses-converter.test.js` (+80 -0) </details> ### 📄 Description ## Description This PR addresses two issues encountered when integrating with browser extensions (specifically [Twemex](https://twemex.com/)): 1. **CORS Policy**: Applied global CORS headers to allow access from browser extensions (e.g., `chrome-extension://...`). Previously, the preflight `OPTIONS` check wasn't sufficient for all extension fetch requests. 2. **Input Format Compatibility**: Enhanced `OpenAIResponsesConverter` to handle input items that: - Lack an explicit `type` property (defaulting to `'message'`). - Use a direct string for `content` instead of an array of objects. ## Context These issues were discovered while using the [Twemex](https://twemex.com/) Chrome extension, which relies on the `/v1/responses` endpoint. The extension sends requests that were previously blocked by CORS and uses a simplified input format that the converter didn't handle. cc @JimmyLv (Twemex author) - FYI, this enables Twemex compatibility with this project. ## Changes - Modified `src/request-handler.js` to set CORS headers on all requests. - Updated `src/converters/strategies/OpenAIResponsesConverter.js` to support flexible input formats. - Added tests: `tests/cors-config.test.js` and `tests/openai-responses-converter.test.js`. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 07:18:46 +03:00
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/AIClient-2-API-justlovemaki#273
No description provided.