diff options
author | crupest <crupest@outlook.com> | 2020-06-05 16:51:42 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-06-05 16:51:42 +0800 |
commit | 0ea07270b008d6f11155bf131d31a2d000d6442b (patch) | |
tree | 0bdebf7c38c15a2268d07b2436b6ab3e2bf1233f /Timeline/Startup.cs | |
parent | 84efc7812457a10074ea8b55534abc4948e5ae1c (diff) | |
download | timeline-0ea07270b008d6f11155bf131d31a2d000d6442b.tar.gz timeline-0ea07270b008d6f11155bf131d31a2d000d6442b.tar.bz2 timeline-0ea07270b008d6f11155bf131d31a2d000d6442b.zip |
feat(back): Add option to use proxy to serve front end in development.
Diffstat (limited to 'Timeline/Startup.cs')
-rw-r--r-- | Timeline/Startup.cs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/Timeline/Startup.cs b/Timeline/Startup.cs index 77b48466..35c47712 100644 --- a/Timeline/Startup.cs +++ b/Timeline/Startup.cs @@ -21,7 +21,6 @@ using Timeline.Services; namespace Timeline
{
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Performance", "CA1822:Mark members as static")]
public class Startup
{
private readonly bool disableFrontEnd;
@@ -91,7 +90,7 @@ namespace Timeline options.UseSqlite($"Data Source={pathProvider.GetDatabaseFilePath()}");
});
- if (!disableFrontEnd)
+ if (!disableFrontEnd && !Environment.IsDevelopment())
{
services.AddSpaStaticFiles(config =>
{
@@ -121,7 +120,7 @@ namespace Timeline app.UseRouting();
- if (!disableFrontEnd)
+ if (!disableFrontEnd && !Environment.IsDevelopment())
{
app.UseSpaStaticFiles(new StaticFileOptions
{
@@ -145,7 +144,14 @@ namespace Timeline if (Environment.IsDevelopment())
{
- SpaServices.SpaDevelopmentServerMiddlewareExtensions.UseSpaDevelopmentServer(spa, packageManager: "yarn", npmScript: "install-and-start", port: 3000);
+ if (Configuration.GetValue<bool?>(ApplicationConfiguration.FrontEndProxyOnlyKey) ?? false)
+ {
+ spa.UseProxyToSpaDevelopmentServer(new UriBuilder("http", "localhost", 3000).Uri);
+ }
+ else
+ {
+ SpaServices.SpaDevelopmentServerMiddlewareExtensions.UseSpaDevelopmentServer(spa, packageManager: "yarn", npmScript: "install-and-start", port: 3000);
+ }
}
});
}
|