Compare commits

..

2 Commits

Author SHA1 Message Date
semantic-release-bot
8f77736a69 chore(release): 1.0.0-dev.2 [skip ci]
# [1.0.0-dev.2](https://github.com/ReVanced/revanced-api/compare/v1.0.0-dev.1...v1.0.0-dev.2) (2024-07-11)

### Bug Fixes

* Configure CORS correctly ([2ed4cf3](2ed4cf3b40))
2024-07-11 01:52:59 +00:00
oSumAtrIX
2ed4cf3b40 fix: Configure CORS correctly 2024-07-11 03:50:48 +02:00
5 changed files with 22 additions and 22 deletions

View File

@@ -1,3 +1,10 @@
# [1.0.0-dev.2](https://github.com/ReVanced/revanced-api/compare/v1.0.0-dev.1...v1.0.0-dev.2) (2024-07-11)
### Bug Fixes
* Configure CORS correctly ([2ed4cf3](https://github.com/ReVanced/revanced-api/commit/2ed4cf3b40caeb6181d068d411344e6732000f22))
# 1.0.0-dev.1 (2024-07-10) # 1.0.0-dev.1 (2024-07-10)

View File

@@ -10,5 +10,8 @@ contributors-repositories = [
"revanced-manager", "revanced-manager",
] ]
api-version = 1 api-version = 1
cors = { host = "*.revanced.app", sub-domains = [] } cors-allowed-hosts = [
endpoint = "https://api.revanced.app" "revanced.app",
"*.revanced.app"
]
endpoint = "https://api.revanced.app"

View File

@@ -1,4 +1,4 @@
org.gradle.parallel = true org.gradle.parallel = true
org.gradle.caching = true org.gradle.caching = true
kotlin.code.style = official kotlin.code.style = official
version = 1.0.0-dev.1 version = 1.0.0-dev.2

View File

@@ -13,10 +13,12 @@ fun Application.configureHTTP() {
val configurationRepository = get<ConfigurationRepository>() val configurationRepository = get<ConfigurationRepository>()
install(CORS) { install(CORS) {
allowHost( configurationRepository.corsAllowedHosts.forEach { host ->
host = configurationRepository.cors.host, allowHost(
subDomains = configurationRepository.cors.subDomains, host = host,
) schemes = listOf("http", "https")
)
}
} }
install(RateLimit) { install(RateLimit) {

View File

@@ -19,7 +19,7 @@ import java.io.File
* @property integrations The source of the integrations. * @property integrations The source of the integrations.
* @property contributorsRepositoryNames The names of the repositories to get contributors from. * @property contributorsRepositoryNames The names of the repositories to get contributors from.
* @property apiVersion The version to use for the API. * @property apiVersion The version to use for the API.
* @property cors The CORS configuration. * @property corsAllowedHosts The hosts allowed to make requests to the API.
* @property endpoint The endpoint of the API. * @property endpoint The endpoint of the API.
*/ */
@Serializable @Serializable
@@ -31,7 +31,8 @@ internal class ConfigurationRepository(
val contributorsRepositoryNames: Set<String>, val contributorsRepositoryNames: Set<String>,
@SerialName("api-version") @SerialName("api-version")
val apiVersion: Int = 1, val apiVersion: Int = 1,
val cors: Cors, @SerialName("cors-allowed-hosts")
val corsAllowedHosts: Set<String>,
val endpoint: String, val endpoint: String,
) { ) {
/** /**
@@ -61,19 +62,6 @@ internal class ConfigurationRepository(
@SerialName("public-key-file") @SerialName("public-key-file")
val publicKeyFile: File, val publicKeyFile: File,
) )
/**
* The CORS configuration.
*
* @property host The host of the API to configure CORS.
* @property subDomains The subdomains to allow for CORS.
*/
@Serializable
internal class Cors(
val host: String,
@SerialName("sub-domains")
val subDomains: List<String>,
)
} }
private object RegexSerializer : KSerializer<Regex> { private object RegexSerializer : KSerializer<Regex> {