fix baseurl in links
Some checks failed
/ build-container (push) Has been cancelled

This commit is contained in:
Finn 2024-11-23 01:50:46 -08:00
parent f1209d3b6b
commit 511897164e
3 changed files with 7 additions and 5 deletions

View file

@ -10,5 +10,5 @@
<body>
<div id="wrapper">
<a href="/">Home</a>
<a href="{{ $.BaseURL }}">Home</a>
<div id="main">

View file

@ -1,6 +1,6 @@
{{ template "header.html" . }}
<header>{{ if eq .Data.lock.Name "" }}Lock #{{ .Data.lock.ID }}{{ else }}{{ .Data.lock.Name }}{{ end }}</header>
[ <a href="/locks/{{ .Data.lock.ID }}/edit">rename</a> ]<br />
[ <a href="{{ $.BaseURL }}/locks/{{ .Data.lock.ID }}/edit">rename</a> ]<br />
<br />
<table border="1">
<tr>
@ -16,7 +16,7 @@
<td>{{ $code.Name }}</td>
<td>{{ $code.Code }}</td>
<td>{{ if $code.Enabled }}enabled{{ else }}disabled{{ end }}</td>
<td>[ <a href="/locks/{{ $.Data.lock.ID }}/codes/{{ $code.Slot }}">edit</a> ]</td>
<td>[ <a href="{{ $.BaseURL }}/locks/{{ $.Data.lock.ID }}/codes/{{ $code.Slot }}">edit</a> ]</td>
</tr>
{{ end }}
</table>

View file

@ -72,7 +72,8 @@ func lockEditHandler(c echo.Context) error {
return err
}
return c.Redirect(http.StatusFound, fmt.Sprintf("/locks/%d", lockID))
baseURL := c.Request().Header.Get("X-Ingress-Path")
return c.Redirect(http.StatusFound, fmt.Sprintf("%s/locks/%d", baseURL, lockID))
}
func lockCodeEditHandler(c echo.Context) error {
@ -162,5 +163,6 @@ func lockCodeEditHandler(c echo.Context) error {
return err
}
return c.Redirect(http.StatusFound, fmt.Sprintf("/locks/%d", lockID))
baseURL := c.Request().Header.Get("X-Ingress-Path")
return c.Redirect(http.StatusFound, fmt.Sprintf("%s/locks/%d", baseURL, lockID))
}