@mmmbuto/zai-codex-bridge 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/server.js +6 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mmmbuto/zai-codex-bridge",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Local proxy that translates OpenAI Responses API format to Z.AI Chat Completions format for Codex",
5
5
  "main": "src/server.js",
6
6
  "bin": {
package/src/server.js CHANGED
@@ -181,7 +181,11 @@ function translateChatToResponses(chatResponse) {
181
181
  * Make upstream request to Z.AI
182
182
  */
183
183
  async function makeUpstreamRequest(path, body, headers) {
184
- const url = new URL(path, ZAI_BASE_URL);
184
+ // Ensure base URL ends with / for proper path concatenation
185
+ const baseUrl = ZAI_BASE_URL.endsWith('/') ? ZAI_BASE_URL : ZAI_BASE_URL + '/';
186
+ // Remove leading slash from path to avoid replacing base URL path
187
+ const cleanPath = path.startsWith('/') ? path.slice(1) : path;
188
+ const url = new URL(cleanPath, baseUrl);
185
189
 
186
190
  const upstreamHeaders = {
187
191
  'Content-Type': 'application/json',
@@ -191,6 +195,7 @@ async function makeUpstreamRequest(path, body, headers) {
191
195
  log('info', 'Upstream request:', {
192
196
  url: url.href,
193
197
  path: path,
198
+ cleanPath: cleanPath,
194
199
  base: ZAI_BASE_URL,
195
200
  hasAuth: !!upstreamHeaders.Authorization
196
201
  });