From 886415d7dd093e52ef0fd3af839c8a9c11b1f32a Mon Sep 17 00:00:00 2001 From: Cannon Lock Date: Mon, 21 Oct 2024 13:36:11 -0500 Subject: [PATCH] Fix mimetypes for web responses --- web_ui/ui.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/web_ui/ui.go b/web_ui/ui.go index 82317afe4..d0eaa643d 100644 --- a/web_ui/ui.go +++ b/web_ui/ui.go @@ -349,20 +349,27 @@ func handleWebUIResource(ctx *gin.Context) { file, _ := webAssets.ReadFile(notFoundFilePath) ctx.Data( http.StatusNotFound, - mime.TypeByExtension(notFoundFilePath), + mime.TypeByExtension(path.Ext(notFoundFilePath)), file, ) } else { // If the file is found, return the file ctx.Data( http.StatusOK, - mime.TypeByExtension(filePath), + mime.TypeByExtension(path.Ext(filePath)), file, ) } } func configureWebResource(engine *gin.Engine) { + + // Register the MIME type for .txt files + err := mime.AddExtensionType(".txt", "text/plain") + if err != nil { + log.Errorf("Failed to register MIME type: %v", err) + } + engine.GET("/view/*requestPath", handleGlobusPages, handleWebUIRedirect,