chore: add location header

This commit is contained in:
johnnyjoy
2024-08-18 10:20:50 +08:00
parent 80548aaf2c
commit a3943f5b2d
3 changed files with 42 additions and 1 deletions

View File

@ -92,9 +92,13 @@ func (s *FrontendService) registerRoutes(e *echo.Echo) {
}
metric.Enqueue("shortcut view")
// Only set the `Location` header if the link is a valid URI.
if util.ValidateURI(shortcut.Link) {
c.Response().Header().Set("Location", shortcut.Link)
}
// Inject shortcut metadata into `index.html`.
indexHTML := strings.ReplaceAll(rawIndexHTML, headerMetadataPlaceholder, generateShortcutMetadata(shortcut).String())
return c.HTML(http.StatusOK, indexHTML)
return c.HTML(http.StatusSeeOther, indexHTML)
})
e.GET("/c/:collectionName", func(c echo.Context) error {