Skip to content

Commit

Permalink
fix(suite-web): start using local sharedworker on localhost and produ…
Browse files Browse the repository at this point in the history
…ction
  • Loading branch information
mroz22 committed Feb 11, 2025
1 parent a52342a commit 9449dab
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
11 changes: 11 additions & 0 deletions packages/suite-build/configs/web.webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@ const config: webpack.Configuration = {
concurrency: 100,
},
}),
new CopyWebpackPlugin({
patterns: [
{
from: path.join(
__dirname,
'../../connect-iframe/build/workers/sessions-background-sharedworker.js',
),
to: path.join(baseDir, 'build', 'static'),
},
],
}),
// Html files
...routes.map(
route =>
Expand Down
9 changes: 4 additions & 5 deletions suite-common/connect-init/src/connectInitThunks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,13 @@ export const connectInitThunk = createThunk(
// ====================================================== ==================== ====================
// localhost:8000 localhost:8088 NO
// https://dev.suite.sldev.cz/suite-web/develop/web/ https://dev.suite.sldev.cz/connect/develop/ YES - connect
// suite.trezor.io/web connect.trezor.io/9(x.y)/ YES - connect
// suite.trezor.io/web connect.trezor.io/9(x.y)/ NO

let _sessionsBackgroundUrl: string | null = null;

const localSharedWorker = '/static/sessions-background-sharedworker.js';
if (typeof window !== 'undefined' && !isNative()) {
if (window.location.origin.includes('localhost')) {
_sessionsBackgroundUrl = null;
_sessionsBackgroundUrl = localSharedWorker;
} else if (window.location.origin.endsWith('dev.suite.sldev.cz')) {
// we are expecting accompanying connect build at specified location
const assetPrefixArr = (process.env.ASSET_PREFIX || '').split('/').filter(Boolean);
Expand All @@ -141,8 +141,7 @@ export const connectInitThunk = createThunk(

_sessionsBackgroundUrl = `${window.location.origin}/${relevantSegments.join('/')}/workers/sessions-background-sharedworker.js`;
} else {
_sessionsBackgroundUrl =
'https://connect.trezor.io/9/workers/sessions-background-sharedworker.js';
_sessionsBackgroundUrl = localSharedWorker;
}
}

Expand Down

0 comments on commit 9449dab

Please sign in to comment.