Database problem ?

iampaulosilva
PRO

a year ago

Hi im new to railway and ive just created a project with a postgre db. All went fine ,migrations created the tables and the project is up online.alltho when i try to use any post method i get 500 error. Could it be any db configuration? Cuz the project works fine on my local machine. thanks

5 Replies

a year ago

Are you sure you are explicitly using https?


iampaulosilva
PRO

a year ago

Can i invite you to my project?


a year ago

That wouldn't be necessary, please answer my question at your earliest convenience.


iampaulosilva
PRO

a year ago

Im unsure tbh.im very new but my program.cs looks like this :builder.Services.AddDbContext<AppDbContext>(options =>

{

options.UseNpgsql("Host=postgres.railway.internal;Port=5432;Username=postgres;Password=*****;Database=railway;SslMode=Require;Trust Server Certificate=True");

});

// Add services to the container.

builder.Services.AddControllersWithViews();

builder.Services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();

builder.Services.AddAutoMapper(typeof(Program));

builder.Services.AddScoped<IBookInterface, BookService >();

builder.Services.AddScoped<IUserInterface, UserService>();

builder.Services.AddScoped<IAuthenticationInterface, AuthenticationService>();

builder.Services.AddScoped<ISessionInterface, SessionService>();

builder.Services.AddScoped<IHomeInterface, HomeService>();

builder.Services.AddScoped<ILoanInterface, LoanService>();

builder.Services.AddScoped<IReportInterface, ReportService>();

builder.Services.AddSession(options =>

{

options.Cookie.HttpOnly = true;

options.Cookie.IsEssential = true;

});

var app = builder.Build();

if (builder.Environment.IsProduction() && builder.Configuration.GetValue<int?>("PORT") is not null)

builder.WebHost.UseUrls($"http://*:{builder.Configuration.GetValue<int>("PORT")}");

var context = app.Services.CreateScope().ServiceProvider.GetRequiredService<AppDbContext>();

await context.Database.MigrateAsync();

// Configure the HTTP request pipeline.

if (!app.Environment.IsDevelopment())

{

app.UseExceptionHandler("/Home/Error");

// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.

app.UseHsts();

}

app.UseHttpsRedirection();

app.UseStaticFiles();

app.UseRouting();

app.UseAuthorization();

app.UseSession();

app.MapControllerRoute(

name: "default",

pattern: "{controller=Home}/{action=Index}/{id?}");

app.Run();


iampaulosilva
PRO

a year ago

Its like the db server goes down or somethong

Attachments


Database problem ? - Railway Help Station