diff options
author | crupest <crupest@outlook.com> | 2020-06-03 18:58:03 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-06-03 18:58:03 +0800 |
commit | f6efa149ee219a92065435a4a2ed240ab84162da (patch) | |
tree | 009d01b1be81108ec783ed2d225a626df6b76c42 /Timeline/Startup.cs | |
parent | d393e939282dc394c655e10ce6016725519dc3f9 (diff) | |
download | timeline-f6efa149ee219a92065435a4a2ed240ab84162da.tar.gz timeline-f6efa149ee219a92065435a4a2ed240ab84162da.tar.bz2 timeline-f6efa149ee219a92065435a4a2ed240ab84162da.zip |
Fix #87 .
Diffstat (limited to 'Timeline/Startup.cs')
-rw-r--r-- | Timeline/Startup.cs | 39 |
1 files changed, 26 insertions, 13 deletions
diff --git a/Timeline/Startup.cs b/Timeline/Startup.cs index afcb97ac..77b48466 100644 --- a/Timeline/Startup.cs +++ b/Timeline/Startup.cs @@ -24,10 +24,14 @@ namespace Timeline [System.Diagnostics.CodeAnalysis.SuppressMessage("Performance", "CA1822:Mark members as static")]
public class Startup
{
+ private readonly bool disableFrontEnd;
+
public Startup(IConfiguration configuration, IWebHostEnvironment environment)
{
Environment = environment;
Configuration = configuration;
+
+ disableFrontEnd = Configuration.GetValue<bool?>(ApplicationConfiguration.DisableFrontEndKey) ?? false;
}
public IWebHostEnvironment Environment { get; }
@@ -87,10 +91,13 @@ namespace Timeline options.UseSqlite($"Data Source={pathProvider.GetDatabaseFilePath()}");
});
- services.AddSpaStaticFiles(config =>
+ if (!disableFrontEnd)
{
- config.RootPath = "ClientApp/dist";
- });
+ services.AddSpaStaticFiles(config =>
+ {
+ config.RootPath = "ClientApp/dist";
+ });
+ }
}
@@ -114,10 +121,13 @@ namespace Timeline app.UseRouting();
- app.UseSpaStaticFiles(new StaticFileOptions
+ if (!disableFrontEnd)
{
- ServeUnknownFileTypes = true
- });
+ app.UseSpaStaticFiles(new StaticFileOptions
+ {
+ ServeUnknownFileTypes = true
+ });
+ }
app.UseAuthentication();
app.UseAuthorization();
@@ -127,15 +137,18 @@ namespace Timeline endpoints.MapControllers();
});
- app.UseSpa(spa =>
+ if (!disableFrontEnd)
{
- spa.Options.SourcePath = "ClientApp";
-
- if (Environment.IsDevelopment())
+ app.UseSpa(spa =>
{
- SpaServices.SpaDevelopmentServerMiddlewareExtensions.UseSpaDevelopmentServer(spa, packageManager: "yarn", npmScript: "start", port: 3000);
- }
- });
+ spa.Options.SourcePath = "ClientApp";
+
+ if (Environment.IsDevelopment())
+ {
+ SpaServices.SpaDevelopmentServerMiddlewareExtensions.UseSpaDevelopmentServer(spa, packageManager: "yarn", npmScript: "install-and-start", port: 3000);
+ }
+ });
+ }
}
}
}
|