我正在使用 ASP.NET Core 和 ReactJS 开发一个网站。
开发时,我在运行应用程序的本地计算机上没有遇到任何问题,但是,当尝试在服务器上部署时,使用模板提供的默认 SPA 代码无法正常工作,因为网站给出了以下错误:
我已经看到如果使用可以解决该错误,spa.UseProxyToSpaDevelopmentServer("http://localhost:xxxx/")但它不起作用。
我的Startup.cs样子如下:
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddCors();
services.AddDbContext<ApplicationDbContext>(options =>
{
options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"));
});
//services.AddDefaultIdentity<ApplicationUser>(options => options.SignIn.RequireConfirmedAccount = true)
// .AddEntityFrameworkStores<ApplicationDbContext>();
services.AddIdentity<ApplicationUser, IdentityRole>()
.AddRoleManager<RoleManager<IdentityRole>>()
.AddDefaultUI()
.AddDefaultTokenProviders()
.AddEntityFrameworkStores<ApplicationDbContext>();
services.AddIdentityServer()
.AddApiAuthorization<ApplicationUser, ApplicationDbContext>();
services.AddAuthentication()
.AddIdentityServerJwt(); …Run Code Online (Sandbox Code Playgroud)