Skip to content

Commit ca1f46d

Browse files
committed
feat: added runtime environment configuration
Refs: KK-1513
1 parent be3f562 commit ca1f46d

39 files changed

Lines changed: 689 additions & 243 deletions

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,7 @@ report
3838
sonar-report.json
3939

4040
sonar-report.xml
41+
42+
public/env-config.js
43+
public/test-env-config.js
44+

CHANGELOG.md

Lines changed: 38 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -410,101 +410,90 @@ See https://github.com/City-of-Helsinki/kukkuu-ui/milestone/6?closed=1
410410

411411
## [3.15.7](https://github.com/City-of-Helsinki/kukkuu-ui/compare/kukkuu-ui-v3.15.6...kukkuu-ui-v3.15.7) (2026-05-11)
412412

413-
414413
### Dependencies
415414

416-
* Bump @babel/plugin-transform-modules-systemjs ([2a000c7](https://github.com/City-of-Helsinki/kukkuu-ui/commit/2a000c7e86370f0bedfaac690ea44ed4368accc0))
417-
* Bump fast-uri from 3.0.6 to 3.1.2 ([c6c0b4c](https://github.com/City-of-Helsinki/kukkuu-ui/commit/c6c0b4cd253a3e07ff5e912ecf162324ba7cf6f8))
415+
- Bump @babel/plugin-transform-modules-systemjs ([2a000c7](https://github.com/City-of-Helsinki/kukkuu-ui/commit/2a000c7e86370f0bedfaac690ea44ed4368accc0))
416+
- Bump fast-uri from 3.0.6 to 3.1.2 ([c6c0b4c](https://github.com/City-of-Helsinki/kukkuu-ui/commit/c6c0b4cd253a3e07ff5e912ecf162324ba7cf6f8))
418417

419418
## [3.15.6](https://github.com/City-of-Helsinki/kukkuu-ui/compare/kukkuu-ui-v3.15.5...kukkuu-ui-v3.15.6) (2026-04-23)
420419

421-
422420
### Bug Fixes
423421

424-
* Refresh profile context after enrolment mutations ([2b16723](https://github.com/City-of-Helsinki/kukkuu-ui/commit/2b16723bf0c4d12ac0a7bb6a1ebc63dc516f6a7f))
422+
- Refresh profile context after enrolment mutations ([2b16723](https://github.com/City-of-Helsinki/kukkuu-ui/commit/2b16723bf0c4d12ac0a7bb6a1ebc63dc516f6a7f))
425423

426424
## [3.15.5](https://github.com/City-of-Helsinki/kukkuu-ui/compare/kukkuu-ui-v3.15.4...kukkuu-ui-v3.15.5) (2026-04-22)
427425

428-
429426
### Bug Fixes
430427

431-
* New invitation fix ([528209f](https://github.com/City-of-Helsinki/kukkuu-ui/commit/528209f35835afdab6ce3b350f31ee8c1a48e00a))
432-
428+
- New invitation fix ([528209f](https://github.com/City-of-Helsinki/kukkuu-ui/commit/528209f35835afdab6ce3b350f31ee8c1a48e00a))
433429

434430
### Dependencies
435431

436-
* Bump dompurify from 3.3.2 to 3.4.0 ([9d61167](https://github.com/City-of-Helsinki/kukkuu-ui/commit/9d61167d6b3ab54ce444ce3f9ce2baea1c7ce717))
432+
- Bump dompurify from 3.3.2 to 3.4.0 ([9d61167](https://github.com/City-of-Helsinki/kukkuu-ui/commit/9d61167d6b3ab54ce444ce3f9ce2baea1c7ce717))
437433

438434
## [3.15.4](https://github.com/City-of-Helsinki/kukkuu-ui/compare/kukkuu-ui-v3.15.3...kukkuu-ui-v3.15.4) (2026-04-09)
439435

440-
441436
### Bug Fixes
442437

443-
* Restore typecheck for HDS select wrappers ([6d3bf37](https://github.com/City-of-Helsinki/kukkuu-ui/commit/6d3bf37b4f97ebb2956aa444afc57d6736e5154b))
444-
438+
- Restore typecheck for HDS select wrappers ([6d3bf37](https://github.com/City-of-Helsinki/kukkuu-ui/commit/6d3bf37b4f97ebb2956aa444afc57d6736e5154b))
445439

446440
### Dependencies
447441

448-
* Add lodash resolution to fix code injection vulnerabilities ([f4eab7e](https://github.com/City-of-Helsinki/kukkuu-ui/commit/f4eab7e329413cd23a9f6466089b0e01d28dc42d))
449-
* Bump lodash from 4.17.23 to 4.18.1 ([496b78f](https://github.com/City-of-Helsinki/kukkuu-ui/commit/496b78f61516c89d6f9b6268e95c0f472cf338bf))
450-
* Bump lodash-es from 4.17.23 to 4.18.1 ([7b1c034](https://github.com/City-of-Helsinki/kukkuu-ui/commit/7b1c0342163770277aeccc1bc5b9b03ac7fd3104))
451-
* Bump vite from 8.0.3 to 8.0.5 ([442633e](https://github.com/City-of-Helsinki/kukkuu-ui/commit/442633e5d96c6ba6685ee1eab97e835b378e09dd))
452-
* Enforce documented security resolutions ([6562061](https://github.com/City-of-Helsinki/kukkuu-ui/commit/6562061b5f78af13c8b00f5ae7fbff2cda7a2868))
453-
* Remove redux dependency and update import statements for thunk ([3b69397](https://github.com/City-of-Helsinki/kukkuu-ui/commit/3b693974538898a92bc5b9a64e6814c87ca474b4))
454-
* Remove unused @graphql-codegen/add package ([a1c0799](https://github.com/City-of-Helsinki/kukkuu-ui/commit/a1c0799b3fdd9a4389c3287191554a33bec8337b))
455-
* Remove unused @types/react-redux package ([7e0bbc8](https://github.com/City-of-Helsinki/kukkuu-ui/commit/7e0bbc860d2fb3d4508909fb2884f998b8efc3da))
456-
* Remove unused @vitejs/plugin-react package ([7811a38](https://github.com/City-of-Helsinki/kukkuu-ui/commit/7811a38a4adf8cd930510a17e8ec9d9375f954de))
457-
* Remove unused codecov package ([e1eceb7](https://github.com/City-of-Helsinki/kukkuu-ui/commit/e1eceb74b8ce5c81e890bb0ca41993f988df0d73))
458-
* Remove unused css-what package ([a4d65c4](https://github.com/City-of-Helsinki/kukkuu-ui/commit/a4d65c410cd4eadf4272b6137d07b1c21476477c))
459-
* Remove unused html-react-parser package ([fb10a04](https://github.com/City-of-Helsinki/kukkuu-ui/commit/fb10a04829eb661c653123e82dea5e547ae0df48))
460-
* Remove unused oidc-client package ([f63fcc1](https://github.com/City-of-Helsinki/kukkuu-ui/commit/f63fcc1ff8864e7f30e56461b5bb0c7c6aa432f3))
461-
* Remove unused prop-types package ([0ebd17d](https://github.com/City-of-Helsinki/kukkuu-ui/commit/0ebd17dab842211c5d7f095aea5c227247efcf74))
462-
* Replace Vite ESLint plugin with @nabla/vite-plugin-eslint ([3a500d2](https://github.com/City-of-Helsinki/kukkuu-ui/commit/3a500d2e76cabf2e86ca2348c1edd31bcbff3735))
463-
* Update @city-of-helsinki/react-helsinki-headless-cms to 3.0.1 ([5911400](https://github.com/City-of-Helsinki/kukkuu-ui/commit/59114003831d0f3f172707f083211f1a5c705b95))
464-
* Update babel runtime to version 7.29.2 ([d844620](https://github.com/City-of-Helsinki/kukkuu-ui/commit/d8446205b725fd895bb306bf03eb506ec5347639))
465-
* Update brace-expansion to versions 1.1.13 and 2.0.3 ([2cf56c3](https://github.com/City-of-Helsinki/kukkuu-ui/commit/2cf56c3a7aed59aa27065a2893a04cce61c3e4c4))
466-
* Update js-yaml to version 4.1.1 ([2d92676](https://github.com/City-of-Helsinki/kukkuu-ui/commit/2d926767a94ae3f2d6fcefa7d2aef8e45146282a))
467-
* Update minimatch to fix ReDoS vulnerability ([4111555](https://github.com/City-of-Helsinki/kukkuu-ui/commit/41115551f72e0eb3aa90e2dc4fe71bb16221dcbe))
468-
* Update rollup packages to version 4.60.1 ([84dde13](https://github.com/City-of-Helsinki/kukkuu-ui/commit/84dde134740c8d635d495c397abb5e000b47cd9d))
469-
* Update sass to 1.98.0 and immutable to 5.1.5 for security ([b3efbc1](https://github.com/City-of-Helsinki/kukkuu-ui/commit/b3efbc10cd64b6440c3ad55ecf8e86fb46399eab))
470-
* Update underscore to fix ReDoS vulnerability ([60b5012](https://github.com/City-of-Helsinki/kukkuu-ui/commit/60b5012fec0912a73d4b315ab2d1ccdaf4c43e59))
471-
* Upgrade to Vite 8 and fix redux-persist compatibility ([a725ed5](https://github.com/City-of-Helsinki/kukkuu-ui/commit/a725ed5a642eeeb7027124412a42abd8510f2b30))
442+
- Add lodash resolution to fix code injection vulnerabilities ([f4eab7e](https://github.com/City-of-Helsinki/kukkuu-ui/commit/f4eab7e329413cd23a9f6466089b0e01d28dc42d))
443+
- Bump lodash from 4.17.23 to 4.18.1 ([496b78f](https://github.com/City-of-Helsinki/kukkuu-ui/commit/496b78f61516c89d6f9b6268e95c0f472cf338bf))
444+
- Bump lodash-es from 4.17.23 to 4.18.1 ([7b1c034](https://github.com/City-of-Helsinki/kukkuu-ui/commit/7b1c0342163770277aeccc1bc5b9b03ac7fd3104))
445+
- Bump vite from 8.0.3 to 8.0.5 ([442633e](https://github.com/City-of-Helsinki/kukkuu-ui/commit/442633e5d96c6ba6685ee1eab97e835b378e09dd))
446+
- Enforce documented security resolutions ([6562061](https://github.com/City-of-Helsinki/kukkuu-ui/commit/6562061b5f78af13c8b00f5ae7fbff2cda7a2868))
447+
- Remove redux dependency and update import statements for thunk ([3b69397](https://github.com/City-of-Helsinki/kukkuu-ui/commit/3b693974538898a92bc5b9a64e6814c87ca474b4))
448+
- Remove unused @graphql-codegen/add package ([a1c0799](https://github.com/City-of-Helsinki/kukkuu-ui/commit/a1c0799b3fdd9a4389c3287191554a33bec8337b))
449+
- Remove unused @types/react-redux package ([7e0bbc8](https://github.com/City-of-Helsinki/kukkuu-ui/commit/7e0bbc860d2fb3d4508909fb2884f998b8efc3da))
450+
- Remove unused @vitejs/plugin-react package ([7811a38](https://github.com/City-of-Helsinki/kukkuu-ui/commit/7811a38a4adf8cd930510a17e8ec9d9375f954de))
451+
- Remove unused codecov package ([e1eceb7](https://github.com/City-of-Helsinki/kukkuu-ui/commit/e1eceb74b8ce5c81e890bb0ca41993f988df0d73))
452+
- Remove unused css-what package ([a4d65c4](https://github.com/City-of-Helsinki/kukkuu-ui/commit/a4d65c410cd4eadf4272b6137d07b1c21476477c))
453+
- Remove unused html-react-parser package ([fb10a04](https://github.com/City-of-Helsinki/kukkuu-ui/commit/fb10a04829eb661c653123e82dea5e547ae0df48))
454+
- Remove unused oidc-client package ([f63fcc1](https://github.com/City-of-Helsinki/kukkuu-ui/commit/f63fcc1ff8864e7f30e56461b5bb0c7c6aa432f3))
455+
- Remove unused prop-types package ([0ebd17d](https://github.com/City-of-Helsinki/kukkuu-ui/commit/0ebd17dab842211c5d7f095aea5c227247efcf74))
456+
- Replace Vite ESLint plugin with @nabla/vite-plugin-eslint ([3a500d2](https://github.com/City-of-Helsinki/kukkuu-ui/commit/3a500d2e76cabf2e86ca2348c1edd31bcbff3735))
457+
- Update @city-of-helsinki/react-helsinki-headless-cms to 3.0.1 ([5911400](https://github.com/City-of-Helsinki/kukkuu-ui/commit/59114003831d0f3f172707f083211f1a5c705b95))
458+
- Update babel runtime to version 7.29.2 ([d844620](https://github.com/City-of-Helsinki/kukkuu-ui/commit/d8446205b725fd895bb306bf03eb506ec5347639))
459+
- Update brace-expansion to versions 1.1.13 and 2.0.3 ([2cf56c3](https://github.com/City-of-Helsinki/kukkuu-ui/commit/2cf56c3a7aed59aa27065a2893a04cce61c3e4c4))
460+
- Update js-yaml to version 4.1.1 ([2d92676](https://github.com/City-of-Helsinki/kukkuu-ui/commit/2d926767a94ae3f2d6fcefa7d2aef8e45146282a))
461+
- Update minimatch to fix ReDoS vulnerability ([4111555](https://github.com/City-of-Helsinki/kukkuu-ui/commit/41115551f72e0eb3aa90e2dc4fe71bb16221dcbe))
462+
- Update rollup packages to version 4.60.1 ([84dde13](https://github.com/City-of-Helsinki/kukkuu-ui/commit/84dde134740c8d635d495c397abb5e000b47cd9d))
463+
- Update sass to 1.98.0 and immutable to 5.1.5 for security ([b3efbc1](https://github.com/City-of-Helsinki/kukkuu-ui/commit/b3efbc10cd64b6440c3ad55ecf8e86fb46399eab))
464+
- Update underscore to fix ReDoS vulnerability ([60b5012](https://github.com/City-of-Helsinki/kukkuu-ui/commit/60b5012fec0912a73d4b315ab2d1ccdaf4c43e59))
465+
- Upgrade to Vite 8 and fix redux-persist compatibility ([a725ed5](https://github.com/City-of-Helsinki/kukkuu-ui/commit/a725ed5a642eeeb7027124412a42abd8510f2b30))
472466

473467
## [3.15.3](https://github.com/City-of-Helsinki/kukkuu-ui/compare/kukkuu-ui-v3.15.2...kukkuu-ui-v3.15.3) (2026-03-23)
474468

475-
476469
### Dependencies
477470

478-
* Bump eslint and plugins Refs: RATY-299 ([49962d6](https://github.com/City-of-Helsinki/kukkuu-ui/commit/49962d66c74e59a87cc1cba0992612b5514e3b1d))
479-
* Bump flatted from 3.4.1 to 3.4.2 ([32aeb0c](https://github.com/City-of-Helsinki/kukkuu-ui/commit/32aeb0c222d4a858277c64d545307a9e90416f32))
471+
- Bump eslint and plugins Refs: RATY-299 ([49962d6](https://github.com/City-of-Helsinki/kukkuu-ui/commit/49962d66c74e59a87cc1cba0992612b5514e3b1d))
472+
- Bump flatted from 3.4.1 to 3.4.2 ([32aeb0c](https://github.com/City-of-Helsinki/kukkuu-ui/commit/32aeb0c222d4a858277c64d545307a9e90416f32))
480473

481474
## [3.15.2](https://github.com/City-of-Helsinki/kukkuu-ui/compare/kukkuu-ui-v3.15.1...kukkuu-ui-v3.15.2) (2026-03-17)
482475

483-
484476
### Dependencies
485477

486-
* Bump flatted from 3.3.2 to 3.4.1 ([f09f026](https://github.com/City-of-Helsinki/kukkuu-ui/commit/f09f026dcf85f438b9689a0bea9b8459ab7d2f8d))
478+
- Bump flatted from 3.3.2 to 3.4.1 ([f09f026](https://github.com/City-of-Helsinki/kukkuu-ui/commit/f09f026dcf85f438b9689a0bea9b8459ab7d2f8d))
487479

488480
## [3.15.1](https://github.com/City-of-Helsinki/kukkuu-ui/compare/kukkuu-ui-v3.15.0...kukkuu-ui-v3.15.1) (2026-03-17)
489481

490-
491482
### Bug Fixes
492483

493-
* Add authentication cookies to consent settings ([d573ace](https://github.com/City-of-Helsinki/kukkuu-ui/commit/d573ace83b398005845c3b621300d550a1cae99c))
484+
- Add authentication cookies to consent settings ([d573ace](https://github.com/City-of-Helsinki/kukkuu-ui/commit/d573ace83b398005845c3b621300d550a1cae99c))
494485

495486
## [3.15.0](https://github.com/City-of-Helsinki/kukkuu-ui/compare/kukkuu-ui-v3.14.2...kukkuu-ui-v3.15.0) (2026-03-17)
496487

497-
498488
### Features
499489

500-
* Update to hds 4.9.0 ([#720](https://github.com/City-of-Helsinki/kukkuu-ui/issues/720)) ([7af8057](https://github.com/City-of-Helsinki/kukkuu-ui/commit/7af80574655a84e84b6f4d03890f90dd854beded))
501-
490+
- Update to hds 4.9.0 ([#720](https://github.com/City-of-Helsinki/kukkuu-ui/issues/720)) ([7af8057](https://github.com/City-of-Helsinki/kukkuu-ui/commit/7af80574655a84e84b6f4d03890f90dd854beded))
502491

503492
### Dependencies
504493

505-
* Add glob@^10.5.0 resolution Refs: RATY-299 ([cb5e88e](https://github.com/City-of-Helsinki/kukkuu-ui/commit/cb5e88e1980562f7e1579fe942531eb13e0a7c83))
506-
* Bump dompurify from 3.2.4 to 3.3.2 ([fffd1b7](https://github.com/City-of-Helsinki/kukkuu-ui/commit/fffd1b7382b43ddf2bd4121d0f7ce420647a3676))
507-
* Migrate eslint to v9 Refs: RATY-299 ([8ecb372](https://github.com/City-of-Helsinki/kukkuu-ui/commit/8ecb372949740ca874115e17136100aa963ef958))
494+
- Add glob@^10.5.0 resolution Refs: RATY-299 ([cb5e88e](https://github.com/City-of-Helsinki/kukkuu-ui/commit/cb5e88e1980562f7e1579fe942531eb13e0a7c83))
495+
- Bump dompurify from 3.2.4 to 3.3.2 ([fffd1b7](https://github.com/City-of-Helsinki/kukkuu-ui/commit/fffd1b7382b43ddf2bd4121d0f7ce420647a3676))
496+
- Migrate eslint to v9 Refs: RATY-299 ([8ecb372](https://github.com/City-of-Helsinki/kukkuu-ui/commit/8ecb372949740ca874115e17136100aa963ef958))
508497

509498
## [3.14.2](https://github.com/City-of-Helsinki/kukkuu-ui/compare/kukkuu-ui-v3.14.1...kukkuu-ui-v3.14.2) (2026-01-28)
510499

Dockerfile

Lines changed: 5 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ WORKDIR /app
77
# 1. Copy needed files for build
88
COPY --chown=default:root package.json pnpm-lock.yaml pnpm-workspace.yaml tsconfig.json tsconfig.node.json ./
99
COPY --chown=default:root ./public ./public
10+
COPY --chown=default:root ./scripts ./scripts
1011

1112
# 2. Run the install
1213
# corepack in the base image will automatically use the version of pnpm
1314
# defined in your package.json 'packageManager' field if present.
1415
RUN pnpm install --frozen-lockfile --ignore-scripts && pnpm store prune
16+
RUN pnpm update-runtime-env
1517

1618
# 3. Copy remaining source files
1719
COPY --chown=default:root index.html vite.config.ts eslint.config.js .prettierrc.json .env* ./
@@ -45,43 +47,8 @@ CMD pnpm exec vite --port 8080 --no-open --host
4547
# ============================================================
4648
FROM appbase AS staticbuilder
4749

48-
# Accept Vite build-time variables from CI/CD docker --build-arg values.
49-
ARG VITE_ENVIRONMENT
50-
ARG VITE_ORIGIN
51-
ARG VITE_API_URI
52-
ARG VITE_CMS_URI
53-
ARG VITE_APPLICATION_NAME
54-
ARG VITE_VERSION
55-
ARG VITE_ELIGIBLE_CITIES
56-
ARG VITE_OIDC_AUTHORITY
57-
ARG VITE_OIDC_CLIENT_ID
58-
ARG VITE_OIDC_KUKKUU_API_CLIENT_ID
59-
ARG VITE_OIDC_SCOPE
60-
ARG VITE_OIDC_RETURN_TYPE
61-
ARG VITE_OIDC_SERVER_TYPE
62-
ARG VITE_OIDC_AUDIENCES
63-
ARG VITE_OIDC_AUTOMATIC_SILENT_RENEW_ENABLED
64-
ARG VITE_OIDC_SESSION_POLLING_INTERVAL_MS
65-
ARG VITE_IDLE_TIMEOUT_IN_MS
66-
ARG VITE_HELSINKI_PROFILE_URL
67-
ARG VITE_MATOMO_URL_BASE
68-
ARG VITE_MATOMO_SITE_ID
69-
ARG VITE_MATOMO_SRC_URL
70-
ARG VITE_MATOMO_ENABLED
71-
ARG VITE_APOLLO_PERSISTED_CACHE_TIME_TO_LIVE_MS
72-
ARG VITE_ENROLMENT_CANCELLATION_TIME_LIMIT_HOURS
73-
ARG VITE_FEATURE_FLAG_SHOW_CORONAVIRUS_INFO
74-
ARG VITE_ADMIN_TICKET_VALIDATION_URL
75-
ARG VITE_SENTRY_DSN
76-
ARG VITE_SENTRY_ENVIRONMENT
77-
ARG VITE_SENTRY_RELEASE
78-
ARG VITE_SENTRY_TRACES_SAMPLE_RATE
79-
ARG VITE_SENTRY_TRACE_PROPAGATION_TARGETS
80-
ARG VITE_SENTRY_REPLAYS_SESSION_SAMPLE_RATE
81-
ARG VITE_SENTRY_REPLAYS_ON_ERROR_SAMPLE_RATE
82-
8350
# Perform the build
84-
ARG REACT_APP_SENTRY_RELEASE
51+
ARG VITE_SENTRY_RELEASE
8552
RUN pnpm build
8653

8754

@@ -90,8 +57,8 @@ RUN pnpm build
9057
# ============================================================
9158
FROM helsinki.azurecr.io/ubi10/nginx-126-spa-standard AS production
9259

93-
ARG REACT_APP_SENTRY_RELEASE
94-
ENV APP_RELEASE=${REACT_APP_SENTRY_RELEASE:-""}
60+
ARG VITE_SENTRY_RELEASE
61+
ENV APP_RELEASE=${VITE_SENTRY_RELEASE:-""}
9562
# 1. Copy the compiled assets
9663
COPY --from=staticbuilder /app/build /usr/share/nginx/html
9764

browser-tests/userRoles.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ export const authorizedGuardian = Role(route(), async (t) => {
2626
console.info('Use "authorizedGuardian" role.');
2727
await authorize(t, browserTestUser);
2828
const currentLocalStorage = await t.eval(() => ({
29-
...window.localStorage,
29+
...globalThis.window.localStorage,
3030
}));
3131
const currentSessionStorage = await t.eval(() => ({
32-
...window.sessionStorage,
32+
...globalThis.window.sessionStorage,
3333
}));
3434
// eslint-disable-next-line no-console
3535
console.debug('authorizedAdmin', {

browser-tests/utils/jwt/clientUtils/login.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ const storeOIDCUserResponse = ClientFunction(
2727
userStoreKey,
2828
oidcUserData,
2929
});
30-
window.sessionStorage.setItem(userStoreKey, JSON.stringify(oidcUserData));
30+
globalThis.window.sessionStorage.setItem(
31+
userStoreKey,
32+
JSON.stringify(oidcUserData)
33+
);
3134
},
3235
{
3336
dependencies: { userStoreKey },
@@ -41,7 +44,7 @@ const storeApiTokenUserReference = ClientFunction(
4144
apiTokenUserReferenceKey,
4245
apiTokenUserReferenceToken,
4346
});
44-
window.sessionStorage.setItem(
47+
globalThis.window.sessionStorage.setItem(
4548
apiTokenUserReferenceKey,
4649
apiTokenUserReferenceToken
4750
);
@@ -59,7 +62,7 @@ const storeApiToken = ClientFunction(
5962
apiClientId,
6063
apiToken,
6164
});
62-
window.sessionStorage.setItem(
65+
globalThis.window.sessionStorage.setItem(
6366
apiTokenStorageKey,
6467
JSON.stringify({
6568
[apiClientId]: apiToken,
@@ -79,7 +82,8 @@ const hasAuthExpired = ClientFunction(
7982
userStoreKey,
8083
});
8184
try {
82-
const userResponseAsString = window.sessionStorage.getItem(userStoreKey);
85+
const userResponseAsString =
86+
globalThis.window.sessionStorage.getItem(userStoreKey);
8387
const storedUserResponse = JSON.parse(userResponseAsString ?? '');
8488
const hasExpired = storedUserResponse?.expires_at * 1000 < Date.now();
8589
if (hasExpired) {

index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
<body>
6363
<noscript>You need to enable JavaScript to run this app.</noscript>
6464
<div id="root"></div>
65+
<script src="/env-config.js"></script>
6566
<script type="module" src="/src/index.tsx"></script>
6667
</body>
6768
</html>

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@
1818
],
1919
"scripts": {
2020
"app:version": "echo \"$npm_package_version\"",
21-
"build": "tsc & vite build",
21+
"update-runtime-env": "tsx --tsconfig ./scripts/tsconfig.json scripts/update-runtime-env.ts",
22+
"build": "pnpm update-runtime-env && tsc && vite build",
2223
"lint": "eslint .",
2324
"format:code": "pnpm lint --fix",
2425
"format:markup": "prettier --config .prettierrc.json --write \"./**/*.{html,json,css,scss,md,mdx}\"",
2526
"generate:graphql": "cross-env DOTENV_CONFIG_PATH=./.env.development.local graphql-codegen -r dotenv/config --config ./codegen.ts",
2627
"serve": "vite preview",
27-
"start": "vite",
28-
"test": "cross-env TZ=Europe/Helsinki vitest run",
28+
"start": "pnpm update-runtime-env && vite",
29+
"test": "cross-env NODE_ENV=test TZ=Europe/Helsinki pnpm update-runtime-env && cross-env TZ=Europe/Helsinki vitest run",
2930
"test:coverage": "cross-env TZ=Europe/Helsinki vitest run --coverage",
3031
"test:staged": "cross-env TZ=Europe/Helsinki vitest related --run",
3132
"test:watch": "cross-env TZ=Europe/Helsinki vitest",
@@ -117,6 +118,7 @@
117118
"rehype-sanitize": "^6.0.0",
118119
"sass": "^1.98.0",
119120
"testcafe": "^3.7.4",
121+
"tsx": "^4.22.0",
120122
"typescript": "^5.7.3",
121123
"validator": "^13.15.22",
122124
"vite": "^8.0.5",

0 commit comments

Comments
 (0)