diff --git a/backend/listen/http_server/https_server.go b/backend/listen/http_server/https_server.go index 7133c472..fca7349e 100644 --- a/backend/listen/http_server/https_server.go +++ b/backend/listen/http_server/https_server.go @@ -28,7 +28,7 @@ import ( olog "log" ) -//go:embed dist/* +//go:embed all:dist/* var local embed.FS var httpsServer *http.Server diff --git a/backend/listen/http_server/public_recovery_test.go b/backend/listen/http_server/public_recovery_test.go index a1e6ff25..b4cafce7 100644 --- a/backend/listen/http_server/public_recovery_test.go +++ b/backend/listen/http_server/public_recovery_test.go @@ -2,6 +2,7 @@ package http_server import ( "crypto/tls" + "io/fs" "net/http" "net/http/httptest" "strings" @@ -63,6 +64,33 @@ func TestPublicRecoveryPageIsServedOnlyFromMailDomain(t *testing.T) { } } +func TestPublicRecoveryServesUnderscorePrefixedBuildAssets(t *testing.T) { + configurePublicRecoveryRouteTest(t) + handler, err := newPublicRecoveryHandler() + if err != nil { + t.Fatal(err) + } + recoveryHandler, ok := handler.(*publicRecoveryHandler) + if !ok { + t.Fatalf("unexpected public recovery handler type %T", handler) + } + + matches, err := fs.Glob(recoveryHandler.frontend, "assets/_plugin-vue_export-helper-*.js") + if err != nil { + t.Fatal(err) + } + if len(matches) == 0 { + t.Fatal("embedded frontend does not contain the Vue export helper asset") + } + + recorder := httptest.NewRecorder() + request := publicRecoveryRequest(http.MethodGet, "https://mx.example.com/"+matches[0]) + handler.ServeHTTP(recorder, request) + if recorder.Code != http.StatusOK { + t.Fatalf("underscore-prefixed asset returned %d, want %d", recorder.Code, http.StatusOK) + } +} + func TestPublicRecoveryPageRequiresConfiguredHTTPSPort(t *testing.T) { configurePublicRecoveryRouteTest(t) config.Instance.HttpsPort = 8443