mirror of
https://github.com/CJackHwang/ds2api.git
synced 2026-05-09 18:57:43 +08:00
Merge pull request #462 from CJackHwang/codex/align-vercel-js-path-with-go-implementation
fix(vercel): align JS stream path guard with Go /chat/completions alias
This commit is contained in:
@@ -88,7 +88,7 @@ function isVercelRuntime() {
|
||||
|
||||
function isNodeStreamSupportedPath(rawURL) {
|
||||
const path = extractPathname(rawURL);
|
||||
return path === '/v1/chat/completions';
|
||||
return path === '/v1/chat/completions' || path === '/chat/completions';
|
||||
}
|
||||
|
||||
function extractPathname(rawURL) {
|
||||
|
||||
@@ -758,9 +758,11 @@ test('shouldSkipPath skips dynamic response/fragments/*/status paths only', () =
|
||||
assert.equal(shouldSkipPath('response/status'), false);
|
||||
});
|
||||
|
||||
test('node stream path guard only allows /v1/chat/completions', () => {
|
||||
test('node stream path guard allows OpenAI v1 and root alias chat completions paths', () => {
|
||||
assert.equal(isNodeStreamSupportedPath('/v1/chat/completions'), true);
|
||||
assert.equal(isNodeStreamSupportedPath('/v1/chat/completions?x=1'), true);
|
||||
assert.equal(isNodeStreamSupportedPath('/chat/completions'), true);
|
||||
assert.equal(isNodeStreamSupportedPath('/chat/completions?x=1'), true);
|
||||
assert.equal(isNodeStreamSupportedPath('/v1beta/models/gemini-2.5-flash:streamGenerateContent'), false);
|
||||
assert.equal(isNodeStreamSupportedPath('/anthropic/v1/messages'), false);
|
||||
});
|
||||
@@ -768,6 +770,7 @@ test('node stream path guard only allows /v1/chat/completions', () => {
|
||||
test('extractPathname strips query only', () => {
|
||||
assert.equal(extractPathname('/v1/chat/completions?stream=true'), '/v1/chat/completions');
|
||||
assert.equal(extractPathname('/v1beta/models/gemini-2.5-flash:streamGenerateContent?key=1'), '/v1beta/models/gemini-2.5-flash:streamGenerateContent');
|
||||
assert.equal(extractPathname('/chat/completions?stream=true'), '/chat/completions');
|
||||
});
|
||||
|
||||
test('setCorsHeaders reflects requested third-party headers and blocks internal-only headers', () => {
|
||||
|
||||
Reference in New Issue
Block a user