fix ollama error (#6418)
This commit is contained in:
parent
e709d200aa
commit
db52057030
@ -182,6 +182,13 @@ export const sendCompletion = async (
|
|||||||
'X-Title': 'Jan',
|
'X-Title': 'Jan',
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
// Add Origin header for local providers to avoid CORS issues
|
||||||
|
...((provider.base_url?.includes('localhost:') || provider.base_url?.includes('127.0.0.1:')) && {
|
||||||
|
fetch: getServiceHub().providers().fetch(),
|
||||||
|
defaultHeaders: {
|
||||||
|
'Origin': 'tauri://localhost',
|
||||||
|
},
|
||||||
|
}),
|
||||||
} as ExtendedConfigOptions)
|
} as ExtendedConfigOptions)
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
|||||||
@ -143,6 +143,12 @@ export class TauriProvidersService extends DefaultProvidersService {
|
|||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add Origin header for local providers to avoid CORS issues
|
||||||
|
// Some local providers (like Ollama) require an Origin header
|
||||||
|
if (provider.base_url.includes('localhost:') || provider.base_url.includes('127.0.0.1:')) {
|
||||||
|
headers['Origin'] = 'tauri://localhost'
|
||||||
|
}
|
||||||
|
|
||||||
// Only add authentication headers if API key is provided
|
// Only add authentication headers if API key is provided
|
||||||
if (provider.api_key) {
|
if (provider.api_key) {
|
||||||
headers['x-api-key'] = provider.api_key
|
headers['x-api-key'] = provider.api_key
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user