Skip to content

Commit

Permalink
Remove CORS headers
Browse files Browse the repository at this point in the history
They are now handled in nginx so it is easier to manage them

But tbh I think Ktor does work with this, I just had forgotten to set the "anonymous" in my Image requests in JS
  • Loading branch information
MrPowerGamerBR committed Sep 21, 2023
1 parent d05522d commit b58a5b9
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 25 deletions.
1 change: 0 additions & 1 deletion backend/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ dependencies {
implementation(libs.ktor.server.netty)
implementation(libs.ktor.server.compression)
implementation(libs.ktor.server.caching.headers)
implementation(libs.ktor.server.cors)
implementation(libs.kotlinx.serialization.json)

implementation(project(":common"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ import io.ktor.server.engine.*
import io.ktor.server.netty.*
import io.ktor.server.plugins.cachingheaders.*
import io.ktor.server.plugins.compression.*
import io.ktor.server.plugins.cors.routing.*
import io.ktor.server.routing.*
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
import kotlinx.serialization.decodeFromString
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
import mu.KotlinLogging
Expand All @@ -22,17 +20,10 @@ import net.perfectdreams.etherealgambi.backend.utils.GIFImageInfo
import net.perfectdreams.etherealgambi.backend.utils.ImageInfo
import net.perfectdreams.etherealgambi.backend.utils.PNGImageInfo
import net.perfectdreams.etherealgambi.backend.utils.SimpleImageInfo
import net.perfectdreams.etherealgambi.data.DefaultImageVariant
import net.perfectdreams.etherealgambi.data.ImageInfoData
import net.perfectdreams.etherealgambi.data.ImageType
import net.perfectdreams.etherealgambi.data.ImageVariant
import net.perfectdreams.etherealgambi.data.ScaleDownToWidthImageVariant
import net.perfectdreams.etherealgambi.data.ScaleDownToWidthImageVariantPreset
import net.perfectdreams.etherealgambi.data.*
import java.io.File
import java.nio.file.StandardCopyOption
import java.util.concurrent.ConcurrentHashMap
import kotlin.concurrent.thread
import kotlin.io.path.moveTo
import kotlin.system.exitProcess

class EtherealGambi {
Expand Down Expand Up @@ -109,19 +100,6 @@ class EtherealGambi {
}
}

// Useful to access and manipulate images in a canvas
install(CORS) {
allowHeader(HttpHeaders.AccessControlAllowOrigin)
allowHeader(HttpHeaders.ContentType)
allowMethod(HttpMethod.Get)
allowMethod(HttpMethod.Post)
allowMethod(HttpMethod.Options)
allowMethod(HttpMethod.Put)
allowMethod(HttpMethod.Patch)
allowMethod(HttpMethod.Delete)
anyHost()
}

routing {
for (route in routes) {
route.register(this)
Expand Down
1 change: 0 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ dependencyResolutionManagement {
library("ktor-server-netty", "io.ktor", "ktor-server-netty").versionRef(ktor)
library("ktor-server-compression", "io.ktor", "ktor-server-compression").versionRef(ktor)
library("ktor-server-caching-headers", "io.ktor", "ktor-server-caching-headers").versionRef(ktor)
library("ktor-server-cors", "io.ktor", "ktor-server-cors").versionRef(ktor)
}
}
}

0 comments on commit b58a5b9

Please sign in to comment.