Skip to content

Commit

Permalink
fix: consider context path in Swagger UI link
Browse files Browse the repository at this point in the history
This matter when LAPIS is operated behind a proxy that has a URL prefix
  • Loading branch information
fengelniederhammer committed Mar 6, 2024
1 parent cd6536d commit 4b12b53
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class ExceptionHandler(private val notFoundView: NotFoundView) : ResponseEntityE
return ResponseEntity
.status(HttpStatus.NOT_FOUND)
.contentType(MediaType.TEXT_HTML)
.body(notFoundView.render())
.body(notFoundView.render(request))
}

return super.handleNoResourceFoundException(ex, headers, status, request)
Expand Down Expand Up @@ -127,9 +127,11 @@ class ExceptionHandler(private val notFoundView: NotFoundView) : ResponseEntityE

@Component
class NotFoundView(private val databaseConfig: DatabaseConfig) {
fun render(): String {
fun render(request: WebRequest): String {
request.contextPath

val uri = ServletUriComponentsBuilder.fromCurrentRequest()
.replacePath("/swagger-ui/index.html")
.replacePath("/${request.contextPath}/swagger-ui/index.html")
.replaceQuery(null)
.fragment(null)
.toUriString()
Expand Down

0 comments on commit 4b12b53

Please sign in to comment.