From 7ad2bf708b27246ed1c4ce02865ddbe4214428d4 Mon Sep 17 00:00:00 2001 From: Rainnny7 Date: Thu, 19 Sep 2024 00:00:05 -0400 Subject: [PATCH] yes? --- src/main/java/cc/pulseapp/api/PulseAPI.java | 19 ++++++++++ .../cc/pulseapp/api/config/AppConfig.java | 36 ------------------- 2 files changed, 19 insertions(+), 36 deletions(-) delete mode 100644 src/main/java/cc/pulseapp/api/config/AppConfig.java diff --git a/src/main/java/cc/pulseapp/api/PulseAPI.java b/src/main/java/cc/pulseapp/api/PulseAPI.java index 57bcdc9..4cac99e 100644 --- a/src/main/java/cc/pulseapp/api/PulseAPI.java +++ b/src/main/java/cc/pulseapp/api/PulseAPI.java @@ -6,6 +6,9 @@ import lombok.extern.log4j.Log4j2; 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.web.servlet.config.annotation.CorsRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import java.io.File; import java.nio.file.Files; @@ -32,4 +35,20 @@ public class PulseAPI { log.info("Found configuration at '{}'", config.getAbsolutePath()); SpringApplication.run(PulseAPI.class, args); // Start the app } + + @Bean + public WebMvcConfigurer corsConfigurer() { + return new WebMvcConfigurer() { + @Override + public void addCorsMappings(@NonNull CorsRegistry registry) { + // Allow all origins to access the API + registry.addMapping("/*") + .allowedOrigins("*") // Allow all origins + .allowedMethods("*") // Allow all methods + .allowedHeaders("*"); // Allow all headers +// registry.addMapping("/*") +// .allowedOrigins("http://localhost:9000"); + } + }; + } } \ No newline at end of file diff --git a/src/main/java/cc/pulseapp/api/config/AppConfig.java b/src/main/java/cc/pulseapp/api/config/AppConfig.java deleted file mode 100644 index 9d9f3e7..0000000 --- a/src/main/java/cc/pulseapp/api/config/AppConfig.java +++ /dev/null @@ -1,36 +0,0 @@ -package cc.pulseapp.api.config; - -import jakarta.annotation.PostConstruct; -import lombok.NonNull; -import lombok.extern.log4j.Log4j2; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.servlet.config.annotation.CorsRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; - -/** - * @author Braydon - */ -@Configuration @Log4j2(topic = "App Config") -public class AppConfig { - @PostConstruct - public void init() { - log.info("App Config initialized"); - } - - @Bean - public WebMvcConfigurer configureCors() { - return new WebMvcConfigurer() { - @Override - public void addCorsMappings(@NonNull CorsRegistry registry) { - log.info("Configuring CORS..."); - - // Allow all origins to access the API - registry.addMapping("*") - .allowedOrigins("*") // Allow all origins - .allowedMethods("*") // Allow all methods - .allowedHeaders("*"); // Allow all headers - } - }; - } -}