refactor: use this in static method
This commit is contained in:
parent
c51a9cecc9
commit
b1250616a7
@ -6,7 +6,7 @@ namespace Mirea.Api.Endpoint.Common.Services;
|
||||
|
||||
public static class UrlHelper
|
||||
{
|
||||
public static string CurrentDomain(HttpContext context) =>
|
||||
public static string GetCurrentDomain(this HttpContext context) =>
|
||||
context.Request.Headers["X-Forwarded-Host"].FirstOrDefault() ?? context.Request.Host.Host;
|
||||
|
||||
private static string CreateSubPath(string? path)
|
||||
|
@ -74,9 +74,11 @@ public partial class SetupController(
|
||||
Response.Cookies.Append("AuthToken", token, new CookieOptions
|
||||
{
|
||||
Path = UrlHelper.GetSubPathWithoutFirstApiName + "api",
|
||||
Domain = UrlHelper.CurrentDomain(ControllerContext.HttpContext),
|
||||
Domain = HttpContext.GetCurrentDomain(),
|
||||
#if !DEBUG
|
||||
Secure = true,
|
||||
HttpOnly = true
|
||||
#endif
|
||||
});
|
||||
return Ok(true);
|
||||
}
|
||||
|
@ -30,9 +30,11 @@ public class AuthController(IOptionsSnapshot<Admin> user, AuthService auth, Pass
|
||||
{
|
||||
Expires = expires,
|
||||
Path = UrlHelper.GetSubPathWithoutFirstApiName + "api",
|
||||
Domain = UrlHelper.CurrentDomain(ControllerContext.HttpContext),
|
||||
Domain = HttpContext.GetCurrentDomain(),
|
||||
#if !DEBUG
|
||||
Secure = true,
|
||||
HttpOnly = true
|
||||
#endif
|
||||
};
|
||||
|
||||
Response.Cookies.Append(name, value, cookieOptions);
|
||||
|
Loading…
Reference in New Issue
Block a user