Skip to content

Commit 923e9c6

Browse files
authored
fix REST OpenAPI redirect (#579)
related to interline-io/tlv2#130
1 parent ea2d4e1 commit 923e9c6

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

server/rest/rest.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,8 @@ func NewServer(graphqlHandler http.Handler) (http.Handler, error) {
5353

5454
// Redirect root to OpenAPI documentation
5555
r.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
56-
// Get the base path from the request URL
57-
basePath := strings.TrimSuffix(r.URL.Path, "/")
58-
// When path is "/", basePath will be empty, which is correct for root
59-
redirectPath := basePath + "/openapi.json"
60-
http.Redirect(w, r, redirectPath, http.StatusMovedPermanently)
56+
cfg := model.ForContext(r.Context())
57+
http.Redirect(w, r, cfg.RestPrefix+"/openapi.json", http.StatusMovedPermanently)
6158
})
6259

6360
// OpenAPI Schema endpoint

0 commit comments

Comments
 (0)