feat: add listen port from env
This commit is contained in:
parent
d87654a355
commit
d45c865f4e
8
.env
8
.env
@ -9,7 +9,7 @@
|
||||
|
||||
# General
|
||||
|
||||
# The path to save the data.
|
||||
# The path to save the data
|
||||
# string
|
||||
# (optional)
|
||||
# Saving logs (if the full path is not specified),
|
||||
@ -18,6 +18,12 @@
|
||||
# If you want to change this value, you need to change the values in Settings.json and move the file itself to the desired location.
|
||||
PATH_TO_SAVE=
|
||||
|
||||
# Internal port configuration
|
||||
# integer
|
||||
# (optional)
|
||||
# Specify the internal port on which the server will listen.
|
||||
INTERNAL_PORT=
|
||||
|
||||
# Security
|
||||
|
||||
# JWT signature token
|
||||
|
@ -16,6 +16,7 @@ using Mirea.Api.Endpoint.Middleware;
|
||||
using Mirea.Api.Security.Services;
|
||||
using System;
|
||||
using System.IO;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
|
||||
namespace Mirea.Api.Endpoint;
|
||||
|
||||
@ -66,6 +67,15 @@ public class Program
|
||||
});
|
||||
});
|
||||
|
||||
if (!string.IsNullOrEmpty(builder.Configuration.GetValue<string>("INTERNAL_PORT")))
|
||||
{
|
||||
builder.WebHost.ConfigureKestrel(options =>
|
||||
{
|
||||
options.ListenLocalhost(
|
||||
int.Parse(builder.Configuration.GetValue<string>("INTERNAL_PORT")!));
|
||||
});
|
||||
}
|
||||
|
||||
builder.Services.Configure<ForwardedHeadersOptions>(options =>
|
||||
{
|
||||
var secretForward = builder.Configuration.Get<GeneralConfig>();
|
||||
|
Loading…
Reference in New Issue
Block a user