fix: get sub url without first "api"
This commit is contained in:
parent
ac4804e864
commit
820828276e
@ -18,5 +18,29 @@ public static class UrlHelper
|
||||
}
|
||||
|
||||
public static string GetSubPath => CreateSubPath(Environment.GetEnvironmentVariable("ACTUAL_SUB_PATH"));
|
||||
|
||||
public static string GetSubPathWithoutFirstApiName
|
||||
{
|
||||
get
|
||||
{
|
||||
var path = GetSubPath;
|
||||
|
||||
if (string.IsNullOrEmpty(path) || path == "/")
|
||||
return CreateSubPath(null);
|
||||
|
||||
var parts = path.Split('/', StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
for (int i = 0; i < parts.Length; i++)
|
||||
{
|
||||
if (!parts[i].Equals("api", StringComparison.CurrentCultureIgnoreCase)) continue;
|
||||
|
||||
parts = parts.Take(i).Concat(parts.Skip(i + 1)).ToArray();
|
||||
break;
|
||||
}
|
||||
|
||||
return CreateSubPath(string.Join("/", parts));
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetSubPathSwagger => CreateSubPath(Environment.GetEnvironmentVariable("SWAGGER_SUB_PATH"));
|
||||
}
|
@ -69,7 +69,7 @@ public partial class SetupController(
|
||||
|
||||
Response.Cookies.Append("AuthToken", token, new CookieOptions
|
||||
{
|
||||
Path = UrlHelper.GetSubPath + "api",
|
||||
Path = UrlHelper.GetSubPathWithoutFirstApiName + "api",
|
||||
Domain = UrlHelper.CurrentDomain(ControllerContext.HttpContext),
|
||||
Secure = true,
|
||||
HttpOnly = true
|
||||
|
@ -29,7 +29,7 @@ public class AuthController(IOptionsSnapshot<Admin> user, AuthService auth, Pass
|
||||
var cookieOptions = new CookieOptions
|
||||
{
|
||||
Expires = expires,
|
||||
Path = UrlHelper.GetSubPath + "api",
|
||||
Path = UrlHelper.GetSubPathWithoutFirstApiName + "api",
|
||||
Domain = UrlHelper.CurrentDomain(ControllerContext.HttpContext),
|
||||
Secure = true,
|
||||
HttpOnly = true
|
||||
|
Loading…
Reference in New Issue
Block a user