Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Ivy/Core/Server/ServerUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public static ServerArgs GetArgs()
TestConnection = parser.GetValue<string?>(parsedArgs, "test-connection", null),
EnableDevTools = parser.GetValue(parsedArgs, "enable-dev-tools", false),
Host = parser.GetValue<string?>(parsedArgs, "host", null),
BasePath = parser.GetValue<string?>(parsedArgs, "path-base", null),
};
serverArgs = serverArgs with { FindAvailablePort = parser.GetValue(parsedArgs, "find-available-port", false) };
if (serverArgs.IsCliCommand)
Expand Down
15 changes: 15 additions & 0 deletions src/Ivy/Server.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,12 @@
#endif
public string? Host { get; set; } = null;

/// <summary>
/// Base path for the application when running behind a reverse proxy (e.g., "/myapp").
/// </summary>
public string? BasePath { get; set; } = null;

/// <summary>

Check failure on line 67 in src/Ivy/Server.cs

View workflow job for this annotation

GitHub Actions / backend-checks

The type 'ServerArgs' already contains a definition for 'BasePath'

Check failure on line 67 in src/Ivy/Server.cs

View workflow job for this annotation

GitHub Actions / backend-checks

The type 'ServerArgs' already contains a definition for 'BasePath'

Check failure on line 67 in src/Ivy/Server.cs

View workflow job for this annotation

GitHub Actions / test

The type 'ServerArgs' already contains a definition for 'BasePath'

Check failure on line 67 in src/Ivy/Server.cs

View workflow job for this annotation

GitHub Actions / test

The type 'ServerArgs' already contains a definition for 'BasePath'

Check failure on line 67 in src/Ivy/Server.cs

View workflow job for this annotation

GitHub Actions / test

The type 'ServerArgs' already contains a definition for 'BasePath'

Check failure on line 67 in src/Ivy/Server.cs

View workflow job for this annotation

GitHub Actions / test

The type 'ServerArgs' already contains a definition for 'BasePath'

Check failure on line 67 in src/Ivy/Server.cs

View workflow job for this annotation

GitHub Actions / backend-checks

The type 'ServerArgs' already contains a definition for 'BasePath'

Check failure on line 67 in src/Ivy/Server.cs

View workflow job for this annotation

GitHub Actions / backend-checks

The type 'ServerArgs' already contains a definition for 'BasePath'
/// True when the process is running a CLI-only command (--describe, --describe-connection, --test-connection)
/// that needs DI but should not bind a real port.
/// </summary>
Expand Down Expand Up @@ -108,6 +113,11 @@
_args = _args with { Host = host };
}

if (_args.BasePath == null && Environment.GetEnvironmentVariable("BASE_PATH") is { } basePath)
{
_args = _args with { BasePath = basePath };
}

_args = _args with
{
AssetAssembly = _args.AssetAssembly ?? Assembly.GetCallingAssembly(),
Expand Down Expand Up @@ -765,6 +775,11 @@
app.UseHttpsRedirection();
}

if (!string.IsNullOrEmpty(_args.BasePath))
{
app.UsePathBase(_args.BasePath);
}

var logger = _args.Verbose ? app.Services.GetRequiredService<ILogger<Server>>() : new NullLogger<Server>();


Expand Down
Loading