Skip to content

Commit 24c3ea5

Browse files
author
bourgeoa
committed
fix(auth): avoid SharedWorker startup on localhost dev http
Skip WebSession worker initialization for localhost/127.0.0.1 over http and use SessionCore with IndexedDB directly. This prevents browser SecurityError noise from file:// worker resolution in local dev while keeping normal session behavior in other environments.
1 parent 5935525 commit 24c3ea5

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/authSession/authSession.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,14 @@ class IndexedDbSessionDatabase implements SessionDatabase {
148148
}
149149

150150
function createSession (): OidcSession {
151+
const shouldSkipWorkerInLocalDev = typeof window !== 'undefined' &&
152+
window.location.protocol === 'http:' &&
153+
/^(localhost|127\.0\.0\.1)$/.test(window.location.hostname)
154+
155+
if (shouldSkipWorkerInLocalDev) {
156+
return new SessionCore(undefined, { database: new IndexedDbSessionDatabase() })
157+
}
158+
151159
try {
152160
return new WebSession()
153161
} catch (error) {

0 commit comments

Comments
 (0)