@@ -10,6 +10,14 @@ export class SyncService {
1010 private syncing = false ;
1111 private processor : any = null ;
1212
13+ private getEffectiveUrl ( url : string ) : string {
14+ // If we've configured a Vite proxy and are running on localhost, use the proxy path
15+ if ( url . includes ( 'influxdb3.westernformularacing.org' ) && window . location . hostname === 'localhost' ) {
16+ return '/influx-api' ;
17+ }
18+ return url ;
19+ }
20+
1321 private async getProcessor ( ) {
1422 if ( ! this . processor ) {
1523 this . processor = await createCanProcessor ( ) ;
@@ -94,10 +102,11 @@ export class SyncService {
94102 token : string ,
95103 bucket : string
96104 ) : Promise < ConnectionTestResult > {
105+ const effectiveUrl = this . getEffectiveUrl ( url ) ;
97106 try {
98- const response = await fetch ( `${ url } /api/v3/query_sql` , {
107+ const response = await fetch ( `${ effectiveUrl } /api/v3/query_sql` , {
99108 method : 'POST' ,
100- credentials : 'include ' ,
109+ credentials : 'omit ' ,
101110 headers : {
102111 'Authorization' : `Bearer ${ token } ` ,
103112 'Content-Type' : 'application/json' ,
@@ -108,19 +117,8 @@ export class SyncService {
108117 if ( response . ok ) {
109118 return { ok : true , message : `Connected to ${ bucket } ` } ;
110119 } else {
111- const redirectedToAccess = response . redirected && / c d n - c g i \/ a c c e s s \/ l o g i n / i. test ( response . url ) ;
112- if ( redirectedToAccess ) {
113- return {
114- ok : false ,
115- message : `Cloudflare Access login required. Open ${ url } in this browser and sign in with Google, then test again.` ,
116- } ;
117- }
118-
119120 const text = await response . text ( ) ;
120- const accessHint = response . status === 401 || response . status === 403
121- ? ' Cloudflare Access session may be missing; sign in to Access in this browser.'
122- : '' ;
123- return { ok : false , message : `${ response . status } ${ response . statusText } : ${ text . slice ( 0 , 120 ) } ${ accessHint } ` } ;
121+ return { ok : false , message : `${ response . status } ${ response . statusText } : ${ text . slice ( 0 , 120 ) } ` } ;
124122 }
125123 } catch ( err ) {
126124 const msg = err instanceof Error ? err . message : String ( err ) ;
@@ -129,7 +127,7 @@ export class SyncService {
129127 return {
130128 ok : false ,
131129 message : isNetworkErr
132- ? `Cannot reach ${ url } — check URL/network. If this endpoint is behind Cloudflare Access, sign in to Access in this browser first .`
130+ ? `Cannot reach ${ url } — check URL/network/CORS .`
133131 : msg ,
134132 } ;
135133 }
@@ -146,12 +144,13 @@ export class SyncService {
146144 bucket : string ,
147145 lines : string [ ]
148146 ) {
147+ const effectiveUrl = this . getEffectiveUrl ( url ) ;
149148 // InfluxDB 3 / InfluxDB 2 write endpoint: /api/v2/write
150- const writeUrl = `${ url } /api/v2/write?org=${ org } &bucket=${ bucket } &precision=ns` ;
149+ const writeUrl = `${ effectiveUrl } /api/v2/write?org=${ org } &bucket=${ bucket } &precision=ns` ;
151150
152151 const response = await fetch ( writeUrl , {
153152 method : 'POST' ,
154- credentials : 'include ' ,
153+ credentials : 'omit ' ,
155154 headers : {
156155 'Authorization' : `Token ${ token } ` ,
157156 'Content-Type' : 'text/plain; charset=utf-8' ,
0 commit comments