Skip to content

feat: Add AppSetting for frontend asset base url and param in cli#18850

Open
bjorntore wants to merge 20 commits into
mainfrom
feat/controller-frontend-version-appsetting
Open

feat: Add AppSetting for frontend asset base url and param in cli#18850
bjorntore wants to merge 20 commits into
mainfrom
feat/controller-frontend-version-appsetting

Conversation

@bjorntore
Copy link
Copy Markdown
Contributor

@bjorntore bjorntore commented May 19, 2026

  • Added AppSetting for frontend asset base url and set it to local frontend dev server through studioctl run --dev-frontend or studioctl app build --dev-frontend
  • The AppSetting is only respected in development env at the moment.
  • Support for cookie for selecting frontend version has been removed
  • Frontend version switcher in localtest is now hidden for v9+ apps
  • Version switcher in frontend devtools has been removed
  • Cypress code has been updated to not rewrite frontend URL (now assumes you run with --dev-frontend)
  • Until we have published packages with a bundled frontend and an endpoint to fetch frontend assets from, the app will now display an error message unless started with --dev-frontend

Verification

  • Related issues are connected (if applicable)
  • Your code builds clean without any errors or warnings
  • Manual testing done (required)
  • Relevant automated test added (if you find this hard, leave it and we'll help out)

Summary by CodeRabbit

  • New Features

    • Added --dev-frontend flag to studioctl app run/build to enable local frontend dev‑server integration.
    • Added AppFrontendAssetBaseUrl app setting to serve frontend CSS/JS from a custom base URL in Development.
  • Bug Fixes / Behaviour

    • Index page uses configured frontend asset base URL in Development when provided; falls back to CDN otherwise.
  • Tests

    • Added and updated tests verifying index asset URLs and PDF request behaviour with the new configuration.

Review Change Stack

@github-actions github-actions Bot added the skip-releasenotes Issues that do not make sense to list in our release notes label May 19, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 19, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Replace cookie-based frontend version overrides with a configurable AppFrontendAssetBaseUrl used in Development; HomeController/IndexPageGenerator use the setting, PdfGeneratorClient no longer injects the cookie or depends on host/http-context, CLI adds --dev-frontend and propagates the value to run environments and image builds, tests and fixtures updated accordingly.

Changes

Local Frontend Asset URL Configuration

Layer / File(s) Summary
Configuration schema and public contracts
src/App/backend/src/Altinn.App.Core/Configuration/AppSettings.cs, src/App/backend/src/Altinn.App.Core/Internal/App/IIndexPageGenerator.cs, src/App/backend/test/Altinn.App.Core.Tests/PublicApiTests.PublicApi_ShouldNotChange_Unintentionally.verified.txt, src/App/backend/src/Altinn.App.Core/Configuration/PlatformFrontendSettings.cs
Adds nullable AppFrontendAssetBaseUrl to AppSettings, removes AppFrontendCdnBaseUrl from platform settings, and updates public API/IndexPageGenerator contract and snapshots to reflect constructor/signature changes.
Index page generation and controller wiring
src/App/backend/src/Altinn.App.Core/Internal/App/IndexPageGenerator.cs, src/App/backend/src/Altinn.App.Api/Controllers/HomeController.cs
HomeController.Index computes a Development-only appFrontendAssetBaseUrlOverride from settings and passes it to IndexPageGenerator.Generate, which templates CSS/JS links from the resolved base URL (or returns placeholder HTML when unset).
Runtime localtest app selection & UI
src/Runtime/localtest/src/Controllers/HomeController.cs, src/Runtime/localtest/src/Models/StartAppModel.cs, src/Runtime/localtest/src/Views/*
Introduce AppSelectionOption with ShowFrontendVersionSwitcher; views and scripts toggle frontend-version UI per selected app.
PdfGeneratorClient dependency and cookie removal
src/App/backend/src/Altinn.App.Core/Infrastructure/Clients/Pdf/PdfGeneratorClient.cs
Removed IHttpContextAccessor and IHostEnvironment constructor dependencies, added optional Telemetry parameter, and deleted development-only frontendVersion cookie rewrite/injection in PDF requests.
Integration fixture wiring for runtime env
src/App/backend/test/Altinn.App.Integration.Tests/_fixture/AppFixture.cs, src/App/backend/test/Altinn.App.Integration.Tests/_fixture/StudioctlEnvironment.cs
AppFixture derives appFrontendAssetBaseUrl and passes it into StudioctlAppProcess.Start; RunStudioctl sets AppSettings__AppFrontendAssetBaseUrl env var when provided; fixture HttpClient no longer sets a frontendVersion cookie.
Tests and PDF updates
src/App/backend/test/Altinn.App.Api.Tests/Controllers/HomeControllerTest_AppFrontendAssetBaseUrl.cs, src/App/backend/test/Altinn.App.Api.Tests/Controllers/PdfControllerTests.cs, src/App/backend/test/Altinn.App.Core.Tests/Internal/Pdf/PdfServiceTests.cs
Added tests for configured/default frontend asset URLs. Updated PDF-related tests to construct PdfGeneratorClient without environment/HttpContext dependencies and removed cookie-based expectations.
CLI run/build flags and env propagation
src/cli/internal/cmd/run.go, src/cli/internal/cmd/app/run.go, src/cli/internal/cmd/app/env.go, src/cli/internal/cmd/*_test.go, src/cli/internal/appimage/spec.go
Added --dev-frontend flag and runAppFrontendAssetBaseUrl helper, added AppFrontendAssetBaseUrl to run option structs, pass value into newAppRunEnv/addRunDefaults, wire into Docker/.NET run and image build flows via SetAppFrontendAssetBaseURL, and added tests for parsing and env precedence.
Frontend cleanup (DevTools/versioning)
src/App/frontend/src/features/devtools/*, src/App/frontend/src/utils/versioning/*, src/App/frontend/src/types/shared.ts, src/App/frontend/src/utils/urls/appUrlHelper.ts, src/App/frontend/src/setupTests.ts
Removed VersionSwitcher and version-compare helpers, removed platform CDN frontend URL exposure from shared types and helpers, updated devtools UI and test setup mocks.
E2E support & CI
src/App/frontend/test/e2e/support/start-app-instance.ts, CI workflow/action YAML, infra/runtime/apps-config/*
E2E start-app logic no longer rewrites frontend assets or sets frontendVersion cookie; GitHub action and workflow pass --dev-frontend for run/build steps; infra ConfigMaps removed AppFrontendCdnBaseUrl key.
Authentication token resolver update
src/App/backend/src/Altinn.App.Core/Internal/Auth/AuthenticationTokenResolver.cs, src/App/backend/test/Altinn.App.Core.Tests/Internal/Auth/AuthenticationTokenResolverTest.cs
Changed the hard-coded orgNumber used when constructing the localtest token URL and updated the corresponding test expected URL.

Sequence Diagram(s)

sequenceDiagram
  participant CLI
  participant RunCommand
  participant Topology
  participant EnvBuilder
  participant ImageBuilder
  participant Runtime
  participant HomeController
  participant IndexPageGenerator

  CLI->>RunCommand: parse --dev-frontend
  RunCommand->>Topology: query for frontend dev-server base URL
  Topology-->>RunCommand: return dev-server base URL
  RunCommand->>EnvBuilder: pass appFrontendAssetBaseUrl
  EnvBuilder->>Runtime: set AppSettings__AppFrontendAssetBaseUrl env var (process/container)
  RunCommand->>ImageBuilder: call SetAppFrontendAssetBaseURL(spec, value)
  Runtime->>HomeController: HTTP GET /
  HomeController->>IndexPageGenerator: Generate(..., appFrontendAssetBaseUrlOverride)
  IndexPageGenerator-->>HomeController: HTML using {{appFrontendAssetBaseUrl}} for CSS/JS
  HomeController-->>Runtime: 200 OK (index page)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

backend, frontend, solution/studio/designer, quality/testing

Suggested reviewers

  • olemartinorg
  • martinothamar

🐰 A little rabbit hops with glee,

Config set free from cookie spree,
CLI flag whispers dev-server tune,
Index and PDFs follow soon—
Local assets shining under the moon. ✨

🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The PR description covers the main changes clearly but lacks specific verification of manual testing as required by the template checklist. Complete the manual testing verification checkbox and provide details on what was manually tested to ensure the --dev-frontend functionality works as expected across both CLI and application flows.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The pull request title accurately summarises the main objective: adding an AppSetting for frontend asset base URL and integrating it into the CLI.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/controller-frontend-version-appsetting

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@bjorntore bjorntore changed the title Add appsettings.json prop for frontent version Add AppSetting for frontend asset base url and param in cli May 19, 2026
@bjorntore bjorntore force-pushed the feat/controller-frontend-version-appsetting branch from 1ae637f to 2890688 Compare May 19, 2026 19:41
@bjorntore bjorntore force-pushed the feat/controller-frontend-version-appsetting branch from 2890688 to 3319e9b Compare May 19, 2026 19:51
@bjorntore bjorntore changed the title Add AppSetting for frontend asset base url and param in cli feat: Add AppSetting for frontend asset base url and param in cli May 19, 2026
@bjorntore bjorntore self-assigned this May 19, 2026
@bjorntore bjorntore force-pushed the feat/controller-frontend-version-appsetting branch from 8af13cf to 7064ccb Compare May 20, 2026 07:56
@bjorntore bjorntore force-pushed the feat/controller-frontend-version-appsetting branch from 7064ccb to d75d9d1 Compare May 20, 2026 08:03
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/App/backend/test/Altinn.App.Api.Tests/Controllers/PdfControllerTests.cs (1)

221-223: ⚡ Quick win

Use xUnit type assertions in this test.

Replace result.Should().BeOfType(typeof(FileStreamResult)); with Assert.IsType<FileStreamResult>(result); to align with the project's test assertion conventions. Note: there is an additional instance of this pattern at line 154 that should also be updated.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/App/backend/test/Altinn.App.Api.Tests/Controllers/PdfControllerTests.cs`
around lines 221 - 223, The test in PdfControllerTests asserts the result type
using FluentAssertions; change the assertion to xUnit style by replacing the
FluentAssertions call with Assert.IsType<FileStreamResult>(result) for the
GetPdfPreview test (method invoking pdfController.GetPdfPreview) and update the
other identical assertion in the same test class (the other instance that
currently checks FileStreamResult) so both follow the project's xUnit
convention.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/App/backend/test/Altinn.App.Api.Tests/Controllers/PdfControllerTests.cs`:
- Around line 221-223: The test in PdfControllerTests asserts the result type
using FluentAssertions; change the assertion to xUnit style by replacing the
FluentAssertions call with Assert.IsType<FileStreamResult>(result) for the
GetPdfPreview test (method invoking pdfController.GetPdfPreview) and update the
other identical assertion in the same test class (the other instance that
currently checks FileStreamResult) so both follow the project's xUnit
convention.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 75b39984-bc26-4a46-b027-a21250d46a07

📥 Commits

Reviewing files that changed from the base of the PR and between 7064ccb and d75d9d1.

📒 Files selected for processing (18)
  • src/App/backend/src/Altinn.App.Api/Controllers/HomeController.cs
  • src/App/backend/src/Altinn.App.Core/Configuration/AppSettings.cs
  • src/App/backend/src/Altinn.App.Core/Infrastructure/Clients/Pdf/PdfGeneratorClient.cs
  • src/App/backend/src/Altinn.App.Core/Internal/App/IIndexPageGenerator.cs
  • src/App/backend/src/Altinn.App.Core/Internal/App/IndexPageGenerator.cs
  • src/App/backend/src/Altinn.App.Core/Internal/Auth/AuthenticationTokenResolver.cs
  • src/App/backend/test/Altinn.App.Api.Tests/Controllers/HomeControllerTest_AppFrontendAssetBaseUrl.cs
  • src/App/backend/test/Altinn.App.Api.Tests/Controllers/PdfControllerTests.cs
  • src/App/backend/test/Altinn.App.Core.Tests/Internal/Auth/AuthenticationTokenResolverTest.cs
  • src/App/backend/test/Altinn.App.Core.Tests/Internal/Pdf/PdfServiceTests.cs
  • src/App/backend/test/Altinn.App.Core.Tests/PublicApiTests.PublicApi_ShouldNotChange_Unintentionally.verified.txt
  • src/App/backend/test/Altinn.App.Integration.Tests/_fixture/AppFixture.cs
  • src/App/backend/test/Altinn.App.Integration.Tests/_fixture/StudioctlEnvironment.cs
  • src/cli/internal/cmd/app/env.go
  • src/cli/internal/cmd/app/run.go
  • src/cli/internal/cmd/app/run_test.go
  • src/cli/internal/cmd/run.go
  • src/cli/internal/cmd/run_internal_test.go
💤 Files with no reviewable changes (1)
  • src/App/backend/src/Altinn.App.Core/Infrastructure/Clients/Pdf/PdfGeneratorClient.cs
✅ Files skipped from review due to trivial changes (1)
  • src/App/backend/src/Altinn.App.Core/Internal/Auth/AuthenticationTokenResolver.cs

@olemartinorg olemartinorg requested a review from a team as a code owner May 20, 2026 10:42
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/actions/app-run-local-env/action.yaml:
- Line 124: The args array currently always includes '--dev-frontend' which
enables a frontend even when the 'run-frontend' toggle/input is false; update
the logic that builds args (the const args = [...] construction) to only push
'--dev-frontend' when the frontend toggle/input (e.g., runFrontend or
inputRunFrontend) is truthy, and also export that input into the action/script
environment so downstream code can read it (add it to the env passed to the
script or use core.exportVariable); reference the args array and the frontend
input name so the flag is conditionally included.

In `@src/Runtime/localtest/src/Views/Home/Index.cshtml`:
- Around line 71-73: The option tag currently emits selected="`@app.Selected`"
which will render selected="False" for non-selected items; instead conditionally
render the selected attribute only when app.Selected is true. Update the option
generation that uses app.Value, app.Selected and app.ShowFrontendVersionSwitcher
so that selected is emitted (e.g., selected or selected="selected") only when
app.Selected is true, leaving no selected attribute for false values.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: dbd2b247-f687-4b73-9819-138ff31e397c

📥 Commits

Reviewing files that changed from the base of the PR and between d75d9d1 and 73c7fa9.

📒 Files selected for processing (29)
  • .github/actions/app-run-local-env/action.yaml
  • .github/workflows/app-frontend-cypress.yml
  • infra/runtime/apps-config/base/apps-runtime-common-env.yaml
  • infra/runtime/apps-config/base/apps-runtime-common.yaml
  • src/App/backend/src/Altinn.App.Core/Configuration/PlatformFrontendSettings.cs
  • src/App/backend/src/Altinn.App.Core/Internal/App/IndexPageGenerator.cs
  • src/App/backend/test/Altinn.App.Api.Tests/Controllers/PdfControllerTests.cs
  • src/App/frontend/src/features/devtools/DevToolsControls.tsx
  • src/App/frontend/src/features/devtools/components/VersionSwitcher/VersionSwitcher.tsx
  • src/App/frontend/src/setupTests.ts
  • src/App/frontend/src/types/shared.ts
  • src/App/frontend/src/utils/urls/appUrlHelper.ts
  • src/App/frontend/src/utils/versioning/versionCompare.test.ts
  • src/App/frontend/src/utils/versioning/versionCompare.ts
  • src/App/frontend/src/utils/versioning/versions.ts
  • src/App/frontend/template.env
  • src/App/frontend/test/e2e/config/localtest.json
  • src/App/frontend/test/e2e/config/tt02.json
  • src/App/frontend/test/e2e/support/start-app-instance.ts
  • src/Runtime/localtest/src/Controllers/HomeController.cs
  • src/Runtime/localtest/src/Models/StartAppModel.cs
  • src/Runtime/localtest/src/Views/Home/Index.cshtml
  • src/Runtime/localtest/src/Views/Shared/_Layout.cshtml
  • src/cli/internal/appimage/spec.go
  • src/cli/internal/appimage/spec_test.go
  • src/cli/internal/cmd/app.go
  • src/cli/internal/cmd/app_build_test.go
  • src/cli/internal/cmd/run.go
  • src/cli/internal/cmd/run_internal_test.go
💤 Files with no reviewable changes (16)
  • src/App/frontend/src/utils/versioning/versions.ts
  • src/App/frontend/src/utils/versioning/versionCompare.test.ts
  • src/App/frontend/test/e2e/config/tt02.json
  • src/App/frontend/src/types/shared.ts
  • src/App/frontend/src/utils/versioning/versionCompare.ts
  • src/App/frontend/src/utils/urls/appUrlHelper.ts
  • src/App/frontend/src/features/devtools/components/VersionSwitcher/VersionSwitcher.tsx
  • src/App/frontend/test/e2e/config/localtest.json
  • src/App/frontend/src/setupTests.ts
  • src/App/backend/src/Altinn.App.Core/Configuration/PlatformFrontendSettings.cs
  • src/App/frontend/template.env
  • infra/runtime/apps-config/base/apps-runtime-common-env.yaml
  • infra/runtime/apps-config/base/apps-runtime-common.yaml
  • src/App/frontend/src/features/devtools/DevToolsControls.tsx
  • src/App/frontend/test/e2e/support/start-app-instance.ts
  • src/App/backend/test/Altinn.App.Api.Tests/Controllers/PdfControllerTests.cs
✅ Files skipped from review due to trivial changes (1)
  • src/Runtime/localtest/src/Views/Shared/_Layout.cshtml

Comment thread .github/actions/app-run-local-env/action.yaml
Comment thread src/Runtime/localtest/src/Views/Home/Index.cshtml Outdated
Comment thread src/cli/internal/appimage/spec.go Outdated
Comment thread src/cli/internal/cmd/app.go Outdated
Ole Martin Handeland added 4 commits May 21, 2026 09:37
… those when running github workflows"

This reverts commit 73c7fa9
… any longer and all callers ran frontend. Running an app without frontend is not even currently supported.
# Conflicts:
#	src/App/backend/test/Altinn.App.Core.Tests/Internal/Auth/AuthenticationTokenResolverTest.cs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-releasenotes Issues that do not make sense to list in our release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants