File tree Expand file tree Collapse file tree 4 files changed +27
-4
lines changed Expand file tree Collapse file tree 4 files changed +27
-4
lines changed Original file line number Diff line number Diff line change @@ -150,10 +150,14 @@ export class ChatService {
150150 }
151151
152152 try {
153+ const currentConfig = config ( ) ;
154+ const apiKey = currentConfig . apiKey ?. toString ( ) . trim ( ) ;
155+
153156 const response = await fetch ( `/v1/chat/completions` , {
154157 method : 'POST' ,
155158 headers : {
156- 'Content-Type' : 'application/json'
159+ 'Content-Type' : 'application/json' ,
160+ ...( apiKey ? { Authorization : `Bearer ${ apiKey } ` } : { } )
157161 } ,
158162 body : JSON . stringify ( requestBody ) ,
159163 signal : this . abortController . signal
@@ -505,9 +509,13 @@ export class ChatService {
505509 */
506510 static async getServerProps ( ) : Promise < ApiLlamaCppServerProps > {
507511 try {
512+ const currentConfig = config ( ) ;
513+ const apiKey = currentConfig . apiKey ?. toString ( ) . trim ( ) ;
514+
508515 const response = await fetch ( `/props` , {
509516 headers : {
510- 'Content-Type' : 'application/json'
517+ 'Content-Type' : 'application/json' ,
518+ ...( apiKey ? { Authorization : `Bearer ${ apiKey } ` } : { } )
511519 }
512520 } ) ;
513521
Original file line number Diff line number Diff line change @@ -135,7 +135,14 @@ export class SlotsService {
135135 }
136136
137137 try {
138- const response = await fetch ( '/slots' ) ;
138+ const currentConfig = config ( ) ;
139+ const apiKey = currentConfig . apiKey ?. toString ( ) . trim ( ) ;
140+
141+ const response = await fetch ( '/slots' , {
142+ headers : {
143+ ...( apiKey ? { Authorization : `Bearer ${ apiKey } ` } : { } )
144+ }
145+ } ) ;
139146 if ( response . ok ) {
140147 const slotsData = await response . json ( ) ;
141148 if ( Array . isArray ( slotsData ) && slotsData . length > 0 ) {
Original file line number Diff line number Diff line change 11import { ChatService } from '$lib/services/chat' ;
2+ import { config } from '$lib/stores/settings.svelte' ;
23
34/**
45 * ServerStore - Server state management and capability detection
@@ -94,7 +95,14 @@ class ServerStore {
9495 }
9596
9697 try {
97- const response = await fetch ( '/slots' ) ;
98+ const currentConfig = config ( ) ;
99+ const apiKey = currentConfig . apiKey ?. toString ( ) . trim ( ) ;
100+
101+ const response = await fetch ( '/slots' , {
102+ headers : {
103+ ...( apiKey ? { Authorization : `Bearer ${ apiKey } ` } : { } )
104+ }
105+ } ) ;
98106
99107 if ( response . status === 501 ) {
100108 console . info ( 'Slots endpoint not implemented - server started without --slots flag' ) ;
You can’t perform that action at this time.
0 commit comments