diff --git a/src/main/java/dev/surl/surl/controller/RedirectController.kt b/src/main/java/dev/surl/surl/controller/RedirectController.kt index be95535..9def47d 100644 --- a/src/main/java/dev/surl/surl/controller/RedirectController.kt +++ b/src/main/java/dev/surl/surl/controller/RedirectController.kt @@ -5,6 +5,7 @@ import dev.surl.surl.service.SurlService import jakarta.validation.Valid import jakarta.validation.constraints.Pattern import org.hibernate.validator.constraints.Length +import org.springframework.http.HttpHeaders import org.springframework.http.HttpStatus import org.springframework.http.ResponseEntity import org.springframework.web.bind.annotation.GetMapping @@ -36,7 +37,9 @@ class RedirectController(private val service: SurlService) { ResponseEntity(Msg(code = -1, msg = "key `$key` not found"), HttpStatus.NOT_FOUND) } else { // 找到,发送302跳转 - ResponseEntity.status(302).location(URI.create(redirectUrl)).build() + ResponseEntity(Msg(msg = "FOUND"), HttpHeaders().apply { + location = URI.create(redirectUrl) + }, HttpStatus.FOUND) } } } \ No newline at end of file