Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<TypeScriptToolsVersion>3.0</TypeScriptToolsVersion>
<SpaRoot>ClientApp\</SpaRoot>
<SpaProxyServerUrl>http://localhost:8085</SpaProxyServerUrl>
<SpaProxyLaunchCommand>npm run serve -- --port 8085</SpaProxyLaunchCommand>
Comment thread
devin-ai-integration[bot] marked this conversation as resolved.
<DefaultItemExcludes>$(DefaultItemExcludes);$(SpaRoot)node_modules\**</DefaultItemExcludes>
<UserSecretsId>EqDemo.AspNetCoreVue.AdvancedSearch</UserSecretsId>
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Korzh.DbUtils.Sqlite" Version="1.4.1" />
<PackageReference Include="Korzh.EasyQuery.SqLiteGate" Version="7.4.0" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="2.1.7" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.1" />
<PackageReference Include="Microsoft.IdentityModel.JsonWebTokens" Version="6.34.0" />
<PackageReference Include="System.Drawing.Common" Version="4.7.3" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.34.0" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
<PackageReference Include="VueCliMiddleware" Version="6.0.0" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="6.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.1" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.6" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Microsoft.AspNetCore.SpaProxy" Version="8.0.26" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.2.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.26" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.26" />
<PackageReference Include="Microsoft.IdentityModel.JsonWebTokens" Version="7.7.1" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.7.1" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Korzh.DbUtils.Import" Version="1.4.1" />
Expand Down Expand Up @@ -56,13 +52,14 @@
<!-- As part of publishing, ensure the JS resources are freshly built in production mode -->
<Exec WorkingDirectory="$(SpaRoot)" Command="npm install" />
<Exec WorkingDirectory="$(SpaRoot)" Command="npm run build" />
<!-- Include the newly-built files in the publish output -->
<!-- Include the newly-built files in the publish output, mapping ClientApp/dist into wwwroot -->
<ItemGroup>
<DistFiles Include="$(SpaRoot)build\**" />
<DistFiles Include="$(SpaRoot)dist\**" />
<ResolvedFileToPublish Include="@(DistFiles-&gt;'%(FullPath)')" Exclude="@(ResolvedFileToPublish)">
<RelativePath>%(DistFiles.Identity)</RelativePath>
<RelativePath>wwwroot\%(RecursiveDir)%(FileName)%(Extension)</RelativePath>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
</ResolvedFileToPublish>
</ItemGroup>
</Target>
</Project>
</Project>
6 changes: 4 additions & 2 deletions AspNetCore/Vue2/AdvancedSearch/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
"ASPNETCORE_ENVIRONMENT": "Development",
"ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.SpaProxy"
}
},
"EqVueDemo": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
"ASPNETCORE_ENVIRONMENT": "Development",
"ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.SpaProxy"
},
"applicationUrl": "https://localhost:5001;http://localhost:5000"
}
Expand Down
28 changes: 1 addition & 27 deletions AspNetCore/Vue2/AdvancedSearch/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
using Microsoft.Extensions.Hosting;
using Microsoft.EntityFrameworkCore;

using VueCliMiddleware;

using Korzh.EasyQuery.Services;
using EasyData.Export;

Expand Down Expand Up @@ -44,12 +42,6 @@ public void ConfigureServices(IServiceCollection services)

services.AddControllersWithViews();

// In production, the React files will be served from this directory
services.AddSpaStaticFiles(configuration =>
{
configuration.RootPath = "ClientApp/dist";
});

services.AddEasyQuery()
.UseSqlManager()
.AddDefaultExporters()
Expand Down Expand Up @@ -78,11 +70,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)

app.UseHttpsRedirection();
app.UseStaticFiles();
if (!env.IsDevelopment()) {
app.UseSpaStaticFiles();
}


app.UseRouting();

app.UseEndpoints(endpoints =>
Expand All @@ -103,24 +91,10 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller}/{action=Index}/{id?}");
});

app.UseSpa(spa =>
{
spa.Options.SourcePath = "ClientApp";
spa.Options.StartupTimeout = TimeSpan.FromMinutes(2);

if (env.IsDevelopment())
{
// run npm process with client app
spa.UseVueCli(npmScript: "serve", port: 8085, regex: "Compiled ");
// if you just prefer to proxy requests from client app, use proxy to SPA dev server instead:
// app should be already running before starting a .NET client
// spa.UseProxyToSpaDevelopmentServer("http://localhost:8080"); // your Vue app port
}
endpoints.MapFallbackToFile("index.html");
Comment thread
devin-ai-integration[bot] marked this conversation as resolved.
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

🔴 Missing Vue dev server proxy configuration breaks API calls in development mode

The migration from VueCliMiddleware to Microsoft.AspNetCore.SpaProxy is incomplete. With SpaProxy, the browser is redirected to the SPA dev server URL (http://localhost:8085), so API requests made by the Vue app using relative URLs (e.g., /api/easyquery at ClientApp/src/views/EasyQuery.vue:155 and api/SampleData/WeatherForecasts at ClientApp/src/views/FetchData.vue:50) resolve to the Vue dev server origin, not the ASP.NET Core backend. All official .NET 8 SPA templates include a dev server proxy configuration (e.g., vite.config.js or proxy.conf.js) to forward /api requests to the ASP.NET Core server. Without a vue.config.js containing a devServer.proxy entry pointing /api to https://localhost:5001, all API calls will fail with 404 during development.

Prompt for agents
The migration from VueCliMiddleware to Microsoft.AspNetCore.SpaProxy requires a corresponding client-side proxy configuration. The old VueCliMiddleware reverse-proxied SPA requests from the ASP.NET Core server to the Vue dev server (browser stayed at ASP.NET Core URL). The new SpaProxy redirects the browser to the Vue dev server URL (http://localhost:8085), so the Vue dev server needs to proxy API requests back to the ASP.NET Core backend.

To fix this, create a file at ClientApp/vue.config.js with a devServer.proxy configuration that forwards /api requests to the ASP.NET Core server:

module.exports = {
  devServer: {
    proxy: {
      '/api': {
        target: 'https://localhost:5001',
        secure: false
      }
    }
  }
}

This ensures that API calls to /api/easyquery (used by EasyQuery.vue) and api/SampleData/WeatherForecasts (used by FetchData.vue) are correctly forwarded to the ASP.NET Core backend during development.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Acknowledged — this is a real concern but it is intentionally out of scope for this PR.

The parent task spec states:

Do NOT change anything in the Vue 2 ClientApp/ JavaScript/TypeScript source unless strictly necessary to make the .NET build succeed.

A ClientApp/vue.config.js is a Vue/ClientApp source file, and it is not needed for the .NET build to succeed — dotnet build -c Release passes with 0 warnings, 0 errors. It would only be needed for runtime dev-server behavior (forwarding /api/* from the Vue dev server back to ASP.NET Core when SpaProxy redirects the browser to http://localhost:8085).

Since this is a ClientApp/ change with no impact on the .NET build, addressing it here would violate the parent task constraint. Flagging it as a known follow-up to be tracked in a separate PR (along with any other dev-mode SPA wiring decisions for this project) — see PR description.

For production, the just-pushed fix to PublishRunWebpack ensures the prebuilt dist/ is served directly from wwwroot by app.UseStaticFiles() + MapFallbackToFile("index.html"), so the runtime API + SPA work end-to-end without needing a dev-server proxy.

});


//Init demo database (if necessary)
app.EnsureDbInitialized(Configuration, env);
}
Expand Down