| 9 | namespace react_dotnet_example |
| 10 | { |
| 11 | public class Startup |
| 12 | { |
| 13 | public Startup(IConfiguration configuration) |
| 14 | { |
| 15 | Configuration = configuration; |
| 16 | } |
| 17 | |
| 18 | public IConfiguration Configuration { get; } |
| 19 | |
| 20 | // This method gets called by the runtime. Use this method to add services to the container. |
| 21 | public void ConfigureServices(IServiceCollection services) |
| 22 | { |
| 23 | |
| 24 | services.AddControllersWithViews(); |
| 25 | |
| 26 | // In production, the React files will be served from this directory |
| 27 | services.AddSpaStaticFiles(configuration => |
| 28 | { |
| 29 | configuration.RootPath = "ClientApp/build"; |
| 30 | }); |
| 31 | } |
| 32 | |
| 33 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. |
| 34 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) |
| 35 | { |
| 36 | if (env.IsDevelopment()) |
| 37 | { |
| 38 | app.UseDeveloperExceptionPage(); |
| 39 | } |
| 40 | else |
| 41 | { |
| 42 | app.UseExceptionHandler("/Error"); |
| 43 | // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. |
| 44 | app.UseHsts(); |
| 45 | } |
| 46 | |
| 47 | app.UseHttpsRedirection(); |
| 48 | app.UseStaticFiles(); |
| 49 | app.UseSpaStaticFiles(); |
| 50 | |
| 51 | app.UseRouting(); |
| 52 | |
| 53 | app.UseEndpoints(endpoints => |
| 54 | { |
| 55 | endpoints.MapControllers(); |
| 56 | }); |
| 57 | |
| 58 | app.UseSpa(spa => |
| 59 | { |
| 60 | spa.Options.SourcePath = "ClientApp"; |
| 61 | |
| 62 | if (env.IsDevelopment()) |
| 63 | { |
| 64 | spa.UseReactDevelopmentServer(npmScript: "start"); |
| 65 | } |
| 66 | }); |
| 67 | } |
| 68 | } |
nothing calls this directly
no outgoing calls
no test coverage detected