Skip to content

Commit e57ea19

Browse files
committed
Db connection ok
1 parent 78695c2 commit e57ea19

3 files changed

Lines changed: 25 additions & 19 deletions

File tree

flight-recorder/src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ const FlightDataRecorder: React.FC = () => {
306306
/>
307307
</div>
308308
<p className="text-[10px] text-slate-500 leading-relaxed border border-slate-700/60 rounded-xl px-3 py-2 bg-slate-900/60">
309-
Cloudflare Access uses your browser SSO session. Sync requests include cookies automatically.
309+
Ensure your Auth Token is correct and the endpoint is accessible from this network.
310310
</p>
311311
</div>
312312
</div>

flight-recorder/src/services/SyncService.ts

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -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 && /cdn-cgi\/access\/login/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',

flight-recorder/vite.config.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ export default defineConfig({
3434
})
3535
],
3636
server: {
37-
port: 5174
37+
port: 5174,
38+
proxy: {
39+
'/influx-api': {
40+
target: 'https://influxdb3.westernformularacing.org',
41+
changeOrigin: true,
42+
rewrite: (path) => path.replace(/^\/influx-api/, ''),
43+
}
44+
}
3845
}
3946
});

0 commit comments

Comments
 (0)