You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Web version with Refresh Worker does not work when loaded from different origin (e.g. CDN) #24
When served and opened in a browser this logs something like:
Uncaught SecurityError: Failed to construct 'SharedWorker': Script at 'https://unpkg.com/@uvdsl/[email protected]/dist/esm/web/RefreshWorker.js' cannot be accessed from origin 'http://localhost:63342'.
at new Me (Session.ts:36:23)
at index.html?_ijt=9864dcv3jn9ceshd0aa7oktlqi&_ij_reload=RELOAD_ON_SAVE:6:7
Possible solution
Provide a RefreshWorker.js on the same origin as the app, that loads the actual worker from CDN:
changed the title [-]Web version with Refresh Worker does not work when loaded from CDN[/-][+]Web version with Refresh Worker does not work when loaded from different origin (e.g. CDN)[/+]on Nov 5, 2025
Thank you for raising this issue.
I am a bit hesitant to support this because there are security considerations that should be kept in mind here.
Please see also the wiki.
new Session(undefined, { workerUrl: './RefreshWorker.js' })
This works!
Whether the app wants to risk the dynamic import is the question the app author has to answer for themselves (yet it is could that you make aware of them)
A way to mitigate this is to download the RefreshWorker.js at build/deploy time and do an integrity check.
Well, I am happy that you found a solution to your problem. And if you really want to do this, then I just want to echo your point that the app creator needs to consider the security of their app in this.
So, from my side, please do not do this. I would not feel comfortable with such a setup. I recommend bundling this library / serving it yourself alongside your app.
Activity
[-]Web version with Refresh Worker does not work when loaded from CDN[/-][+]Web version with Refresh Worker does not work when loaded from different origin (e.g. CDN)[/+]uvdsl commentedon Nov 5, 2025
Thank you for raising this issue.
I am a bit hesitant to support this because there are security considerations that should be kept in mind here.
Please see also the wiki.
angelo-v commentedon Nov 5, 2025
I overlooked that you can actually configure the worker url alreay, so my workarround (despite all security concerns) is already possible:
This works!
Whether the app wants to risk the dynamic import is the question the app author has to answer for themselves (yet it is could that you make aware of them)
A way to mitigate this is to download the RefreshWorker.js at build/deploy time and do an integrity check.
uvdsl commentedon Nov 6, 2025
Well, I am happy that you found a solution to your problem. And if you really want to do this, then I just want to echo your point that the app creator needs to consider the security of their app in this.
So, from my side, please do not do this. I would not feel comfortable with such a setup. I recommend bundling this library / serving it yourself alongside your app.
uvdsl commentedon Dec 3, 2025
@angelo-v, would you consider this issue resolved?
uvdsl commentedon Jan 16, 2026
Please re-open this issue if you consider this issue not yet resolved.