mirror of
https://github.com/XFox111/MuiCharts.git
synced 2026-04-22 06:51:05 +03:00
- Added CORS
- Fixed backed Dockerfile to have /persistence if volume is not attached
This commit is contained in:
@@ -19,6 +19,7 @@ FROM mcr.microsoft.com/dotnet/aspnet:8.0 as runtime
|
|||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
COPY --from=build /app/out ./
|
COPY --from=build /app/out ./
|
||||||
|
RUN mkdir /persistence
|
||||||
|
|
||||||
ENV HTTP_PORTS=80
|
ENV HTTP_PORTS=80
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|||||||
@@ -21,6 +21,17 @@ WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
|
|||||||
|
|
||||||
builder.AddInfrastructure();
|
builder.AddInfrastructure();
|
||||||
|
|
||||||
|
builder.Services.AddCors(options =>
|
||||||
|
{
|
||||||
|
options.AddDefaultPolicy(policy =>
|
||||||
|
{
|
||||||
|
policy
|
||||||
|
.WithOrigins(builder.Configuration.GetValue<string[]>("Cors:Origins") ?? ["*"])
|
||||||
|
.WithMethods(builder.Configuration.GetValue<string[]>("Cors:Methods") ?? ["*"])
|
||||||
|
.AllowAnyHeader();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
builder.Services.AddEndpointsApiExplorer();
|
builder.Services.AddEndpointsApiExplorer();
|
||||||
builder.Services.AddSwaggerGen(options =>
|
builder.Services.AddSwaggerGen(options =>
|
||||||
{
|
{
|
||||||
@@ -46,6 +57,8 @@ WebApplication app = builder.Build();
|
|||||||
if (app.Configuration.GetSection("LettuceEncrypt").Exists())
|
if (app.Configuration.GetSection("LettuceEncrypt").Exists())
|
||||||
app.UseHttpsRedirection();
|
app.UseHttpsRedirection();
|
||||||
|
|
||||||
|
app.UseCors();
|
||||||
|
|
||||||
app.MapControllers();
|
app.MapControllers();
|
||||||
|
|
||||||
app.Run();
|
app.Run();
|
||||||
|
|||||||
@@ -8,5 +8,9 @@
|
|||||||
"AllowedHosts": "*",
|
"AllowedHosts": "*",
|
||||||
"ConnectionStrings": {
|
"ConnectionStrings": {
|
||||||
"DataContext": "Data Source=/persistence/data.db"
|
"DataContext": "Data Source=/persistence/data.db"
|
||||||
|
},
|
||||||
|
"Cors": {
|
||||||
|
"Origins": ["*"],
|
||||||
|
"Methods": ["GET", "POST", "PUT", "DELETE"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user