Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions mcp-worker/src/axiosFetchDefaults.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { describe, expect, test } from 'vitest'
import axios from 'axios'
import { axiosClient } from '../../src/api/apiClient'
import './axiosFetchDefaults'

describe('axiosFetchDefaults', () => {
test('sets a Workers-compatible cache mode on global axios defaults', () => {
expect(axios.defaults.fetchOptions?.cache).toBe('no-store')
})

test('sets a Workers-compatible cache mode on the shared axiosClient', () => {
expect(axiosClient.defaults.fetchOptions?.cache).toBe('no-store')
})
})
13 changes: 13 additions & 0 deletions mcp-worker/src/axiosFetchDefaults.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import axios from 'axios'
import { axiosClient } from '../../src/api/apiClient'

/**
* axios >= 1.20 defaults fetch requests to `cache: 'default'`, which the
* Workers runtime rejects ("Unsupported cache mode: default"). Workers only
* accept `no-store` / `no-cache`, so set an explicit value on both the global
* axios defaults and the shared CLI client instance.
*/
const fetchOptions = { cache: 'no-store' as const }

axios.defaults.fetchOptions = fetchOptions
axiosClient.defaults.fetchOptions = fetchOptions
Comment on lines +12 to +13
1 change: 1 addition & 0 deletions mcp-worker/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import './axiosFetchDefaults'
import OAuthProvider from '@cloudflare/workers-oauth-provider'
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
import type { ToolAnnotations } from '@modelcontextprotocol/sdk/types.js'
Expand Down
Loading