based-ghost/aspnet-core-vue-fullstack-testing

vuejs doesn't work when not in debug mode.

mansurdegirmenci opened this issue · 1 comments

I am using "quasar framework". By default, "index.html" is located in the "dist/spa" folder in the clientapp file. I'm getting a 404 error, I need to make a different setting, but I don't know what it is. Can you help?

image

image

public class Startup
{
    #region ctor

    private IConfiguration Configuration { get; }

    public Startup(IConfiguration configuration) => Configuration = configuration;

    #endregion

    public void ConfigureServices(IServiceCollection services)
    {
        services.AddAutoMapper(typeof(Startup));

        services.AddDbConfigration(Configuration);

        services.AddSpaStaticFiles(opt => opt.RootPath = "clientapp/dist/spa");

        services.AddAuthorization();

        services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
            .AddJwtBearer(_ => { });

        services.HangFireConfigrations(Configuration);

        services.AddRouting();

        #region Repositories

        // services.AddHttpContextAccessor();

        services.AddSingleton<ILayerHangFire, LayerHangFire>();

        services.AddGenericRepository<DataListContext>();

        #endregion

        #region ControllersWithViews

        services.AddControllersWithViews(opt =>
        {
            //opt.Filters.Add(new AutoValidateAntiforgeryTokenAttribute());

            //for Authorization
            //var policy = new AuthorizationPolicyBuilder()
            //.RequireAuthenticatedUser()
            //.Build();

            //config.Filters.Add(new AuthorizeFilter(policy));

            //for Audit.Net
            //opt.Filters.Add(new AuditApiAttribute()
            //{
            //    IncludeHeaders = true,
            //    IncludeModelState = true,
            //    IncludeRequestBody = true,
            //    IncludeResponseBody = true,
            //    IncludeResponseHeaders = true
            //});
        }).AddOData((opt, _) =>
        {
            opt.EnableQueryFeatures(25).AddRouteComponents("api", EdmModelBuilder.GetEdmModel(),
                x => x.AddSingleton<ISearchBinder, MyInternetHatlariSearchBinder>());
        });

        #endregion

        #region SignalR

        services.AddSignalR(configure => { configure.EnableDetailedErrors = true; })
            .AddHubOptions<Server>(_ => { }).AddJsonProtocol(_ => { });

        #endregion
    }

    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    {
        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
        }
        else
        {
            app.UseExceptionHandler("/Error");
        }

        // app.UseSpaStaticFiles();

        app.UseRouting();

        app.UseODataRouteDebug();

        app.UseHangfireDashboard();

        app.UseAuthentication();

        app.UseAuthorization();

        //app.UseAudit(Configuration);

        app.UseEndpoints(endpoints =>
        {
            endpoints.MapControllers();

            endpoints.MapHub<Server>("/Server", opt => { opt.CloseOnAuthenticationExpiration = true; });

            if (System.Diagnostics.Debugger.IsAttached)
            {
                endpoints.MapToVueCliProxy(
                    "{*path}",
                    new SpaOptions
                    {
                        SourcePath = "clientapp"
                    },
                    "serve",
                    regex: "READY",
                    forceKill: true);
            }
            else
            {
                endpoints.MapFallbackToFile("Index.html", new StaticFileOptions
                {
                });
            }
        });
    }
}

@mansurdegirmenci - hey, not sure what the project scaffolding looks like using that framework, but based on your top-level package.json try executing the scripts.build command and see where the client files get generated to and try using that path