Skip to content

Commit e74a2d8

Browse files
committed
Fix CORS for Windows desktop app, improve error logging, and bump to v0.0.9
1 parent fd07d2a commit e74a2d8

7 files changed

Lines changed: 15 additions & 9 deletions

File tree

clients/desktop/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@collapse/desktop",
3-
"version": "0.0.8",
3+
"version": "0.0.9",
44
"private": true,
55
"type": "module",
66
"scripts": {

clients/desktop/src-tauri/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

clients/desktop/src-tauri/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "collapse-desktop"
3-
version = "0.0.8"
3+
version = "0.0.9"
44
edition = "2021"
55

66
[lib]

clients/desktop/src-tauri/tauri.conf.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"$schema": "https://raw.githubusercontent.com/nicehash/tauri/refs/tags/tauri-v2.3.1/crates/tauri-utils/schema.json",
33
"productName": "Collapse",
44
"identifier": "com.hackclub.collapse",
5-
"version": "0.0.8",
5+
"version": "0.0.9",
66
"build": {
77
"frontendDist": "../dist",
88
"devUrl": "http://localhost:1420",

clients/desktop/src/logger.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import { invoke as tauriInvoke } from "@tauri-apps/api/core";
1212
import { listen } from "@tauri-apps/api/event";
13+
import { getVersion } from "@tauri-apps/api/app";
1314

1415
// ---------------------------------------------------------------------------
1516
// Types
@@ -27,6 +28,8 @@ interface LogEntry {
2728

2829
const MAX_ENTRIES = 200;
2930
const entries: LogEntry[] = [];
31+
let appVersion = "unknown";
32+
getVersion().then((v) => { appVersion = v; }).catch(() => {});
3033

3134
function push(level: LogEntry["level"], message: string) {
3235
entries.push({ time: Date.now(), level, message });
@@ -184,7 +187,7 @@ export function getReport(): string {
184187
const platform = navigator.platform || "unknown";
185188
const ua = navigator.userAgent || "";
186189

187-
const lines = [`Collapse Desktop | ${platform} | ${now}`, `UA: ${ua}`, "---"];
190+
const lines = [`Collapse Desktop v${appVersion} | ${platform} | ${now}`, `UA: ${ua}`, "---"];
188191

189192
// Last 100 entries
190193
const recent = entries.slice(-100);

clients/react/src/hooks/useGallery.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export function useGallery({ apiBaseUrl, tokens }: UseGalleryOptions): UseGaller
6363
})
6464
.catch((err) => {
6565
if (!cancelled) {
66-
console.warn("Gallery fetch error:", err);
66+
console.warn("Gallery fetch error:", err instanceof Error ? err.message : err);
6767
setError(err.message);
6868
// Keep showing whatever sessions we had
6969
}

packages/server/src/index.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ const app = Fastify({ logger: true });
1616
await app.register(cors, {
1717
origin: (origin, cb) => {
1818
// Allow: no origin (server-to-server), *.hackclub.com, localhost dev, tauri app
19-
if (!origin || origin.startsWith("tauri://")) {
19+
// Tauri uses tauri:// on macOS/Linux but http://tauri.localhost on Windows
20+
if (!origin || origin.startsWith("tauri://") || origin === "http://tauri.localhost") {
2021
cb(null, true);
2122
return;
2223
}
@@ -28,10 +29,12 @@ await app.register(cors, {
2829
) {
2930
cb(null, true);
3031
} else {
31-
cb(new Error("Not allowed by CORS"), false);
32+
app.log.warn(`CORS rejected origin: ${origin}`);
33+
cb(new Error(`Not allowed by CORS (origin: ${origin})`), false);
3234
}
3335
} catch {
34-
cb(new Error("Not allowed by CORS"), false);
36+
app.log.warn(`CORS rejected origin (malformed): ${origin}`);
37+
cb(new Error(`Not allowed by CORS (origin: ${origin})`), false);
3538
}
3639
},
3740
});

0 commit comments

Comments
 (0)