diff --git a/piikii-output-web/avocado/src/main/kotlin/com/piikii/output/web/avocado/adapter/AvocadoPlaceAutoCompleteAdapter.kt b/piikii-output-web/avocado/src/main/kotlin/com/piikii/output/web/avocado/adapter/AvocadoPlaceAutoCompleteAdapter.kt index 4a026872..e430442b 100644 --- a/piikii-output-web/avocado/src/main/kotlin/com/piikii/output/web/avocado/adapter/AvocadoPlaceAutoCompleteAdapter.kt +++ b/piikii-output-web/avocado/src/main/kotlin/com/piikii/output/web/avocado/adapter/AvocadoPlaceAutoCompleteAdapter.kt @@ -5,7 +5,9 @@ import com.piikii.application.domain.place.OriginPlace import com.piikii.application.port.output.web.OriginPlaceAutoCompletePort import com.piikii.common.exception.ExceptionCode import com.piikii.common.exception.PiikiiException +import com.piikii.output.web.avocado.config.AvocadoProperties import com.piikii.output.web.avocado.parser.AvocadoOriginMapIdParserStrategy +import org.springframework.http.HttpHeaders import org.springframework.stereotype.Component import org.springframework.web.client.RestClient import org.springframework.web.client.body @@ -14,6 +16,7 @@ import org.springframework.web.client.body class AvocadoPlaceAutoCompleteAdapter( private val avocadoOriginMapIdParserStrategy: AvocadoOriginMapIdParserStrategy, private val avocadoApiClient: RestClient, + private val avocadoProperties: AvocadoProperties, ) : OriginPlaceAutoCompletePort { override fun isAutoCompleteSupportedUrl(url: String): Boolean { return avocadoOriginMapIdParserStrategy.getParserBySupportedUrl(url) != null @@ -28,8 +31,10 @@ class AvocadoPlaceAutoCompleteAdapter( url: String, originMapId: OriginMapId, ): OriginPlace { + val id = originMapId.toId() return avocadoApiClient.get() - .uri("/${originMapId.toId()}") + .uri("/$id") + .header(HttpHeaders.REFERER, "${avocadoProperties.url.referer}$id") .retrieve() .body() ?.toOriginPlace(url) diff --git a/piikii-output-web/avocado/src/main/kotlin/com/piikii/output/web/avocado/config/AvocadoConfig.kt b/piikii-output-web/avocado/src/main/kotlin/com/piikii/output/web/avocado/config/AvocadoConfig.kt index cb0127b8..00790f88 100644 --- a/piikii-output-web/avocado/src/main/kotlin/com/piikii/output/web/avocado/config/AvocadoConfig.kt +++ b/piikii-output-web/avocado/src/main/kotlin/com/piikii/output/web/avocado/config/AvocadoConfig.kt @@ -51,6 +51,7 @@ data class AvocadoHttp( data class AvocadoUrl( val regex: Regex, val api: String, + val referer: String, ) { data class Regex( val web: String,