Merge pull request #602 from TeamPiped/cors-allow-patch

Allows all methods in CORS.
This commit is contained in:
Kavin 2023-05-31 04:11:35 +01:00 committed by GitHub
commit 46135a1599
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 4 deletions

View File

@ -4,8 +4,7 @@ import io.activej.http.*;
import io.activej.promise.Promisable;
import org.jetbrains.annotations.NotNull;
import static io.activej.http.HttpHeaders.ACCESS_CONTROL_ALLOW_HEADERS;
import static io.activej.http.HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN;
import static io.activej.http.HttpHeaders.*;
public class CustomServletDecorator implements AsyncServlet {
@ -24,8 +23,10 @@ public class CustomServletDecorator implements AsyncServlet {
HttpHeaderValue headerValue = HttpHeaderValue.of("app;dur=" + (System.nanoTime() - before) / 1000000.0);
return response.withHeader(HEADER, headerValue).withHeader(ACCESS_CONTROL_ALLOW_ORIGIN, "*")
.withHeader(ACCESS_CONTROL_ALLOW_HEADERS, "*, Authorization");
return response.withHeader(HEADER, headerValue)
.withHeader(ACCESS_CONTROL_ALLOW_ORIGIN, "*")
.withHeader(ACCESS_CONTROL_ALLOW_HEADERS, "*, Authorization")
.withHeader(ACCESS_CONTROL_ALLOW_METHODS, "*");
});
}