fix cors allowed methods????
All checks were successful
Deploy API / deploy (ubuntu-latest, 2.44.0) (push) Successful in 49s

This commit is contained in:
Braydon 2024-09-19 00:13:13 -04:00
parent 4ca588b61c
commit 840813bfee

@ -8,13 +8,13 @@ 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;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.util.Arrays;
import java.util.Objects;
/**
@ -49,11 +49,10 @@ public class PulseAPI {
@Override
public void addCorsMappings(@NonNull CorsRegistry registry) {
// Allow all origins to access the API
CorsRegistration registration = registry.addMapping("/**")
.allowedOrigins("*");// Allow all origins
for (HttpMethod method : HttpMethod.values()) {
registration.allowedMethods(method.name());
}
registry.addMapping("/**")
.allowedOrigins("*") // Allow all origins
.allowedMethods(Arrays.stream(HttpMethod.values()).map(HttpMethod::name).toArray(String[]::new)) // Allow all methods
.allowedHeaders("*"); // Allow all headers
}
};
}