Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions apps/web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@
<script>
// Prevent theme flash — apply saved theme before first paint
(function () {
var t = localStorage.getItem('hermes-theme');
if (t && t !== 'light') document.documentElement.setAttribute('data-theme', t);
try {
var t = localStorage.getItem('hermes-theme');
if (t && t !== 'light') document.documentElement.setAttribute('data-theme', t);
} catch(e) { /* localStorage blocked (in-app browsers) */ }
})();
</script>
<!-- Analytics script removed for open source -->
Expand Down
8 changes: 5 additions & 3 deletions apps/web/src/lib/supabase.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ import { IS_TAURI } from './platform';
const INIT_FLAG = '__hermes_api_initialized__';

// In-app browsers (Twitter, Instagram, etc.) can block localStorage/sessionStorage.
// Fall back to an in-memory store so the app still renders.
function safeStorage(storage) {
// Some block the property access itself (throws on `window.localStorage`), others
// allow access but throw on setItem/getItem. Handle both cases.
function safeStorage(type) {
try {
const storage = type === 'session' ? window.sessionStorage : window.localStorage;
const key = '__hermes_storage_test__';
storage.setItem(key, '1');
storage.removeItem(key);
Expand All @@ -33,7 +35,7 @@ function safeStorage(storage) {
export async function initWebApi() {
if (globalThis[INIT_FLAG]) return;

let authStorage = safeStorage(localStorage);
let authStorage = safeStorage('local');
let detectSessionInUrl = true;

if (IS_TAURI) {
Expand Down
Loading