Skip to content

Commit

Permalink
feat(conference-request): enable CORS headers
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronkvanmeerten committed Oct 25, 2024
1 parent 7431511 commit 2294606
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
12 changes: 12 additions & 0 deletions jicofo/src/main/kotlin/org/jitsi/jicofo/ktor/Application.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import io.ktor.server.engine.embeddedServer
import io.ktor.server.netty.Netty
import io.ktor.server.netty.NettyApplicationEngine
import io.ktor.server.plugins.contentnegotiation.ContentNegotiation
import io.ktor.server.plugins.cors.routing.CORS
import io.ktor.server.plugins.statuspages.StatusPages
import io.ktor.server.request.receive
import io.ktor.server.response.respond
Expand Down Expand Up @@ -144,6 +145,17 @@ class Application(

private fun Route.conferenceRequest() {
if (config.enableConferenceRequest) {
install(CORS) {
allowMethod(HttpMethod.Options)
allowMethod(HttpMethod.Post)
allowHeader(HttpHeaders.Authorization)
allowCredentials = true
allowNonSimpleContentTypes = true
allowSameOrigin = true
allowHost(ApplicationRequest.host(), schemes = listOf("https"))
}

options("/conference-request/v1") {}
post("/conference-request/v1") {
val request = try {
call.receive<ConferenceRequest>()
Expand Down
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,11 @@
<artifactId>spotbugs-annotations</artifactId>
<version>${spotbugs.version}</version>
</dependency>
<dependency>
<groupId>io.ktor</groupId>
<artifactId>ktor-server-cors-jvm</artifactId>
<version>${ktor_version}</version>
</dependency>
<!-- runtime -->
<dependency>
<groupId>rusv</groupId>
Expand Down

0 comments on commit 2294606

Please sign in to comment.