Skip to content

Write Vite HTTPS config wrapper to node_modules/.aspire instead of node_modules/.bin#15857

Open
danegsta wants to merge 1 commit intomainfrom
danegsta/viteHttps
Open

Write Vite HTTPS config wrapper to node_modules/.aspire instead of node_modules/.bin#15857
danegsta wants to merge 1 commit intomainfrom
danegsta/viteHttps

Conversation

@danegsta
Copy link
Copy Markdown
Member

@danegsta danegsta commented Apr 3, 2026

Description

The generated aspire.vite.config wrapper was written to node_modules/.bin/ which doesn't exist when package managers hoist dependencies (e.g. yarn workspaces monorepos).

Walk up from the app directory to find the nearest node_modules and write the wrapper to a .aspire subdirectory inside it. This ensures Node.js module resolution can find bare imports like 'vite' while also handling hoisted dependency trees. The import for the user's original config uses an absolute path so it resolves correctly regardless of where the wrapper lives.

The config wrapper generation is moved to the SubscribeHttpsEndpointsUpdate callback (which runs before the cert config callback) so the endpoint scheme is only changed to HTTPS when the wrapper was successfully created. If no node_modules directory is found, a warning is logged and HTTPS config is skipped gracefully.

Fixes #15853

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?

Copilot AI review requested due to automatic review settings April 3, 2026 19:49
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 3, 2026

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 15857

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 15857"

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes Vite HTTPS config wrapper generation in monorepos with hoisted dependencies by no longer writing the generated wrapper under node_modules/.bin (which may not exist), and by deferring HTTPS endpoint scheme changes until wrapper generation succeeds.

Changes:

  • Generate the Vite HTTPS wrapper under the nearest node_modules/.aspire found by walking up from the app directory.
  • Move wrapper generation into SubscribeHttpsEndpointsUpdate and have the cert callback only apply --config + TLS env vars when wrapper generation succeeded.
  • Update JavaScript hosting tests to reflect the new “wrapper path is precomputed” flow.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
tests/Aspire.Hosting.JavaScript.Tests/AddViteAppTests.cs Updates tests to set AspireHttpsConfigPath and validate argument/env mutation based on that path.
src/Aspire.Hosting.JavaScript/ViteAppResource.cs Adds AspireHttpsConfigPath to store the generated wrapper path for later use.
src/Aspire.Hosting.JavaScript/JavaScriptHostingExtensions.cs Implements nearest-node_modules discovery and writes wrapper into node_modules/.aspire; restructures HTTPS callbacks.

…de_modules/.bin

The generated aspire.vite.config wrapper was written to
node_modules/.bin/ which doesn't exist when package managers
hoist dependencies (e.g. yarn workspaces monorepos).

Walk up from the app directory to find the nearest node_modules
and write the wrapper to a .aspire subdirectory inside it. This
ensures Node.js module resolution can find bare imports like
'vite' while also handling hoisted dependency trees. The import
for the user's original config uses a relative path from the
wrapper location.

The SubscribeHttpsEndpointsUpdate callback unconditionally flips
the endpoint scheme to HTTPS (the user opted in). The cert config
callback retains the original precedence for determining which
config to wrap: explicit --config argument > WithViteConfig >
auto-detect default config files.

Fixes #15853

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@danegsta danegsta force-pushed the danegsta/viteHttps branch from 55a2a4d to 71ec0a8 Compare April 3, 2026 20:20
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 3, 2026

🎬 CLI E2E Test Recordings — 55 recordings uploaded (commit 71ec0a8)

View recordings
Test Recording
AddPackageInteractiveWhileAppHostRunningDetached ▶️ View Recording
AddPackageWhileAppHostRunningDetached ▶️ View Recording
AgentCommands_AllHelpOutputs_AreCorrect ▶️ View Recording
AgentInitCommand_DefaultSelection_InstallsSkillOnly ▶️ View Recording
AgentInitCommand_MigratesDeprecatedConfig ▶️ View Recording
AllPublishMethodsBuildDockerImages ▶️ View Recording
AspireAddPackageVersionToDirectoryPackagesProps ▶️ View Recording
AspireUpdateRemovesAppHostPackageVersionFromDirectoryPackagesProps ▶️ View Recording
Banner_DisplayedOnFirstRun ▶️ View Recording
Banner_DisplayedWithExplicitFlag ▶️ View Recording
Banner_NotDisplayedWithNoLogoFlag ▶️ View Recording
CertificatesClean_RemovesCertificates ▶️ View Recording
CertificatesTrust_WithNoCert_CreatesAndTrustsCertificate ▶️ View Recording
CertificatesTrust_WithUntrustedCert_TrustsCertificate ▶️ View Recording
ConfigSetGet_CreatesNestedJsonFormat ▶️ View Recording
CreateAndRunAspireStarterProject ▶️ View Recording
CreateAndRunAspireStarterProjectWithBundle ▶️ View Recording
CreateAndRunEmptyAppHostProject ▶️ View Recording
CreateAndRunJavaEmptyAppHostProject ▶️ View Recording
CreateAndRunJsReactProject ▶️ View Recording
CreateAndRunPythonReactProject ▶️ View Recording
CreateAndRunTypeScriptEmptyAppHostProject ▶️ View Recording
CreateAndRunTypeScriptStarterProject ▶️ View Recording
CreateJavaAppHostWithViteApp ▶️ View Recording
CreateStartAndStopAspireProject ▶️ View Recording
CreateTypeScriptAppHostWithViteApp ▶️ View Recording
DescribeCommandResolvesReplicaNames ▶️ View Recording
DescribeCommandShowsRunningResources ▶️ View Recording
DetachFormatJsonProducesValidJson ▶️ View Recording
DoctorCommand_DetectsDeprecatedAgentConfig ▶️ View Recording
DoctorCommand_WithSslCertDir_ShowsTrusted ▶️ View Recording
DoctorCommand_WithoutSslCertDir_ShowsPartiallyTrusted ▶️ View Recording
GlobalMigration_HandlesCommentsAndTrailingCommas ▶️ View Recording
GlobalMigration_HandlesMalformedLegacyJson ▶️ View Recording
GlobalMigration_PreservesAllValueTypes ▶️ View Recording
GlobalMigration_SkipsWhenNewConfigExists ▶️ View Recording
GlobalSettings_MigratedFromLegacyFormat ▶️ View Recording
InvalidAppHostPathWithComments_IsHealedOnRun ▶️ View Recording
LegacySettingsMigration_AdjustsRelativeAppHostPath ▶️ View Recording
LogsCommandShowsResourceLogs ▶️ View Recording
PsCommandListsRunningAppHost ▶️ View Recording
PsFormatJsonOutputsOnlyJsonToStdout ▶️ View Recording
PublishWithDockerComposeServiceCallbackSucceeds ▶️ View Recording
RestoreGeneratesSdkFiles ▶️ View Recording
RestoreSupportsConfigOnlyHelperPackageAndCrossPackageTypes ▶️ View Recording
RunFromParentDirectory_UsesExistingConfigNearAppHost ▶️ View Recording
RunWithMissingAwaitShowsHelpfulError ▶️ View Recording
SecretCrudOnDotNetAppHost ▶️ View Recording
SecretCrudOnTypeScriptAppHost ▶️ View Recording
StagingChannel_ConfigureAndVerifySettings_ThenSwitchChannels ▶️ View Recording
StopAllAppHostsFromAppHostDirectory ▶️ View Recording
StopAllAppHostsFromUnrelatedDirectory ▶️ View Recording
StopNonInteractiveMultipleAppHostsShowsError ▶️ View Recording
StopNonInteractiveSingleAppHost ▶️ View Recording
StopWithNoRunningAppHostExitsSuccessfully ▶️ View Recording

📹 Recordings uploaded automatically from CI run #23960833521

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AddViteApp HTTPS config injection fails in yarn workspaces monorepos (node_modules hoisting)

2 participants