From 4ca588b61c4911acc1a218309a3536e0c69d6f2a Mon Sep 17 00:00:00 2001 From: Rainnny7 Date: Thu, 19 Sep 2024 00:10:08 -0400 Subject: [PATCH] fix cors allowed methods???? --- src/main/java/cc/pulseapp/api/PulseAPI.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/cc/pulseapp/api/PulseAPI.java b/src/main/java/cc/pulseapp/api/PulseAPI.java index 341a2b0..80b5910 100644 --- a/src/main/java/cc/pulseapp/api/PulseAPI.java +++ b/src/main/java/cc/pulseapp/api/PulseAPI.java @@ -7,6 +7,8 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.security.servlet.UserDetailsServiceAutoConfiguration; import org.springframework.context.annotation.Bean; +import org.springframework.http.HttpMethod; +import org.springframework.web.servlet.config.annotation.CorsRegistration; import org.springframework.web.servlet.config.annotation.CorsRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @@ -47,8 +49,11 @@ public class PulseAPI { @Override public void addCorsMappings(@NonNull CorsRegistry registry) { // Allow all origins to access the API - registry.addMapping("/**") - .allowedOrigins("*"); // Allow all origins + CorsRegistration registration = registry.addMapping("/**") + .allowedOrigins("*");// Allow all origins + for (HttpMethod method : HttpMethod.values()) { + registration.allowedMethods(method.name()); + } } }; }