-
Notifications
You must be signed in to change notification settings - Fork 10.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SPA] Introduces new approach for proxying the SPA templates (#31564)
* A new package Microsoft.AspNetCore.SpaProxy has been added that is used by the templates to launch their development proxy via npm/yarn. * The SPA development proxy for each CLI now is the frontend for the application and proxies the requests to the backend which is the ASP.NET Core application. * At publish time the application assets are copied to the wwwroot. * SpaServices.Extensions has been removed from the templates since it is no longer needed. MapFallbackToFile("index.html") handles unknown requests and serves the SPA entry point. * The templates have been updated to keep using HTTPS with the SPA proxy configured to use the ASP.NET Core HTTPS development certificate via a new aspnetcore-https.js file that ships within the template. * The configuration for angular has been updated with a proxy.conf.js file to proxy requests to the backend. * The entry point for the application in development is now https://localhost:5002 when using https and http://localhost:5002 otherwise.
- Loading branch information
Showing
53 changed files
with
19,562 additions
and
4,500 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/Middleware/Spa/SpaProxy/src/Microsoft.AspNetCore.SpaProxy.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<RemoveDevicePlatformSupport>true</RemoveDevicePlatformSupport> | ||
<!-- This is ok since this assembly is not referenced by any application but it is loaded as a hosting startup | ||
assembly for apps referencing this package--> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Reference Include="Microsoft.AspNetCore.Hosting" /> | ||
<None Update="build\Microsoft.AspNetCore.SpaProxy.targets" Pack="true" PackagePath="build\Microsoft.AspNetCore.SpaProxy.targets" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using System.IO; | ||
using Microsoft.AspNetCore.Hosting; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
[assembly: HostingStartup(typeof(Microsoft.AspNetCore.SpaProxy.SpaHostingStartup))] | ||
|
||
namespace Microsoft.AspNetCore.SpaProxy | ||
{ | ||
internal class SpaHostingStartup : IHostingStartup | ||
{ | ||
public void Configure(IWebHostBuilder builder) | ||
{ | ||
builder.ConfigureServices(services => | ||
{ | ||
if (File.Exists(Path.Combine(AppContext.BaseDirectory, "spa.proxy.json"))) | ||
{ | ||
services.AddHostedService<SpaProxyLaunchManager>(); | ||
} | ||
}); | ||
} | ||
} | ||
} |
Oops, something went wrong.