[F] Fix url passing

This commit is contained in:
Azalea
2024-12-26 08:30:21 -05:00
parent 6a54005472
commit 16762d1a46
2 changed files with 8 additions and 3 deletions

View File

@@ -6,7 +6,6 @@ import jakarta.servlet.http.HttpServletRequest
import jakarta.servlet.http.HttpServletRequestWrapper
import jakarta.servlet.http.HttpServletResponse
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Value
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
import org.springframework.context.annotation.Configuration
@@ -82,12 +81,17 @@ class TokenChecker(
/**
* Request wrapper for rewriting the URI after token check.
*/
class RewriteWrapper(req: HttpServletRequest, token: Str) : HttpServletRequestWrapper(req) {
class RewriteWrapper(val req: HttpServletRequest, token: Str) : HttpServletRequestWrapper(req) {
val replace = "/gs/$token/"
val newUri = req.requestURI.replace(replace, "/g/")
val newUrl = req.requestURL.toString().replace(replace, "/g/")
val newSp = req.servletPath.replace(replace, "/g/")
override fun getHeader(name: String): String? {
if (name == "wrapper original url") return req.requestURL.toString()
return super.getHeader(name)
}
override fun getRequestURI() = newUri
override fun getRequestURL() = StringBuffer(newUrl)
override fun getServletPath() = newSp

View File

@@ -214,7 +214,8 @@ fun ChusanServletController.init() {
val fmt = DateTimeFormatter.ofPattern("uuuu-MM-dd HH:mm:ss")
// Get the request url as te address
val addr = req.requestURL.toString().removeSuffix("GetGameSettingApi")
val addr = (req.getHeader("wrapper original url") ?: req.requestURL.toString())
.removeSuffix("GetGameSettingApi")
mapOf(
"gameSetting" to mapOf(