|
@@ -110,9 +110,9 @@ namespace GxPress.Api
|
|
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
|
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
|
|
{
|
|
|
- var provider = new FileExtensionContentTypeProvider();
|
|
|
- // Add new mappings
|
|
|
- provider.Mappings[".epub"] = "application/octet-stream";
|
|
|
+ //var provider = new FileExtensionContentTypeProvider();
|
|
|
+ // // Add new mappings
|
|
|
+ // provider.Mappings[".epub"] = "application/octet-stream";
|
|
|
if (env.IsDevelopment())
|
|
|
{
|
|
|
app.UseDeveloperExceptionPage();
|
|
@@ -121,9 +121,24 @@ namespace GxPress.Api
|
|
|
app.UseMiddleware<ExceptionMiddleware>();
|
|
|
app.UseRouting();
|
|
|
app.UseJwtAuthorization();
|
|
|
+ var cachePeriod = env.IsDevelopment() ? "600" : "604800";
|
|
|
app.UseStaticFiles(new StaticFileOptions
|
|
|
{
|
|
|
- ContentTypeProvider = provider
|
|
|
+ //ContentTypeProvider = provider,
|
|
|
+ //非标准类型
|
|
|
+ ServeUnknownFileTypes = true,
|
|
|
+ //返回类型
|
|
|
+ DefaultContentType = "application/octet-stream",
|
|
|
+ OnPrepareResponse = ctx =>
|
|
|
+ {
|
|
|
+ // Requires the following import:
|
|
|
+ // using Microsoft.AspNetCore.Http;
|
|
|
+ ctx.Context.Response.Headers.Append("Cache-Control", $"public, max-age={cachePeriod}");
|
|
|
+ ctx.Context.Response.Headers.Append("Access-Control-Allow-Headers", $"X-Requested-With");
|
|
|
+ ctx.Context.Response.Headers.Append("Access-Control-Allow-Origin", $"*");
|
|
|
+ ctx.Context.Response.Headers.Append("Access-Control-Allow-Methods", $"GET,POST,OPTIONS");
|
|
|
+ ctx.Context.Response.Headers.Append("Connection", $"keep-alive");
|
|
|
+ }
|
|
|
});
|
|
|
// app.UseStaticFiles(new StaticFileOptions
|
|
|
// {
|